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

5 comments

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?

0

i tried adding a wait after line 4 but its still the same

0

i edited with new code

1

maybe the zombies aren't triggering the Touched event because they spawned directly on top of the part?

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.