I have this teleport script that runs every 60 seconds, but for some odd reason, it doesn't teleport anyone in an actual server, even though it does work while testing in studio.

function tp()
	local teleport = Vector3.new(0,2,0)
	local players = game.Players:GetChildren()
	for i = 1, #players do
		local player = players[i]
		local humanoidrootpart = player.Character:FindFirstChild("HumanoidRootPart")
		humanoidrootpart.CFrame = CFrame.new(teleport)
		teleport = teleport + Vector3.new(0,5.5,0)
	end
end

It worked fine before I added

teleport = teleport + Vector3.new(0,5.5,0)

and moved

local teleport = Vector3.new(0,2,0)

into the function (it was outside before) but I don't understand how that would ruin the script.

4 comments

0

It turns out that it was moving local teleport = Vector3.new(0,2,0) into the function that caused the problem, but I don't understand why. Can someone explain?

0

And I still don't have a solution to the problem, since I need to reset the teleport variable after every teleport.

0

Is this in a LocalScript or Script?

0

Script.