Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Teleporting zombies only works once?

Asked by 2 years ago
Edited 2 years ago

so in my game there is 2 floors, and what im doing is only the player moves from one floor to the next, i spawn in a part that covers the first floor entirely, and teleports the zombies to the first floor. i do this because the player takes an elevator rather than stairs.

Now, the issue is once the part is spawned in, all the zombies teleport as they should, but once more zombies spawn in they wont be teleported, even though they are touching the teleporting part. heres the script:

function onTouched(part)
    if part.Parent ~= nil then
    local h = part.Parent.Parent:findFirstChild("Zombie")
        if h~=nil then
            h.Torso.CFrame = CFrame.new(-161.76, 62.836, 39.947) 


        end
    end
end

script.Parent.Touched:connect(onTouched)

should i loop the script or something? i am honestly not sure why the newly spawned in zombies arent teleporting

0
Cant confirm this, but could the zombies be loading too slow for the script to find the thing called 'Zombie'? Try adding a wait? Jay123abc2 241 — 2y
0
i tried adding a wait after line 4 but its still the same nick2222 20 — 2y
0
i edited with new code nick2222 20 — 2y
1
maybe the zombies aren't triggering the Touched event because they spawned directly on top of the part? boredlake 256 — 2y
0
If they are touching the part with their torso (so `part.Parent.Parent` will not return the Zombie), try using `FindFirstAncestor` to make sure it's a zombie's bodypart. Miniller 562 — 2y

Answer this question