I’m trying to make a teleport script where it teleports every player inside the game. And it’s not working, I’m getting no errors, I added print statements and they didn’t print. The script I used is a normal script that I put inside of ServerScriptService:
local target = game.Workspace.Target.CFrame
for i, player in ipairs(game.Players:GetChildren()) do
print("Waiting")
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
wait(5)
print("Working")
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
This probably due to the fact that players aren’t loading in before the script is fired. I would use an event like PlayerAdded where for when each player is added they get teleported.
@COUNTYL1MITS adding a wait at the top is not good practice, and you shouldn’t do that normally when waiting for something to load.
My point is it doesn’t matter whether it is for testing things or not, you still shouldn’t practice badly because it can affect how well you script in the future. Even if it is for when a round starts or something, you shouldn’t use wait() like that, you should call it off an event or use WaitForChild() when waiting for something to load in.