|
| 15 Apr 2012 04:26 PM |
im trying to make it so that if your not a zombie you are able to teleport but now it just makes it so that zombies teleport! the output says 17:23:14 - Zombie is not a valid member of Model 17:23:14 - Script "Workspace.Teletrip.TeleTo.Teleport", Line 11 17:23:14 - stack end modelname="TeleFro" function onTouched(part) if part.Parent ~= nil then local h = part.Parent:findFirstChild("Humanoid") if h~=nil then local teleportfrom=script.Parent.Enabled.Value if teleportfrom~=0 then if h==humanoid then return end if h.Parent.Zombie == nil then --HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! local teleportto=script.Parent.Parent:findFirstChild(modelname) if teleportto~=nil then local torso = h.Parent.Torso local location = {teleportto.Position} local i = 1
local x = location[i].x local y = location[i].y local z = location[i].z x = x + math.random(-1, 1) z = z + math.random(-1, 1) y = y + math.random(2, 3)
local cf = torso.CFrame local lx = 0 local ly = y local lz = 0 script.Parent.Enabled.Value=0 teleportto.Enabled.Value=0 torso.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz)) wait(3) script.Parent.Enabled.Value=1 teleportto.Enabled.Value=1 else print("Could not find teleporter!") end end end end end end script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
|
| 15 Apr 2012 04:28 PM |
| if h.Parent.Name ~= "Zombie" then -- Did you mean this? |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 04:34 PM |
| No because i meant a zombie NPC and these zombies have certan scripts that show there health at very random HP and Zombie is a value i put in zombies |
|
|
| Report Abuse |
|
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
|
| 15 Apr 2012 04:37 PM |
| if h.Parent:findFirstChild("Zombie") == nil then |
|
|
| Report Abuse |
|
|
| |
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
|
| 15 Apr 2012 04:59 PM |
Non Zombies don't have the value , so the script cant access it. It like Workspace.NonExistantPart:Remove()
If there is no NonExistantPart, the script will fail.
findFirstChild() checks if it is there and gets the first object with the name. It returns true or false.
|
|
|
| Report Abuse |
|
|