So I made a simple script to teleport all players to one point after a function is called, but for some reason It does not teleport anyone. I didnt get any error in output and yes, I am sure the function runs properly. Here is the script I am using:
local proximity = script.Parent local playersS = game:GetService("Players") local players = playersS:GetChildren() proximity.Triggered:Connect(function() for i,v in pairs(players) do v.Character.HumanoidRootPart.CFrame = workspace.playertpspawn.CFrame end proximity.Enabled = false end)
Does someone know what am I doing wrong?
edit: I have just noticed that the issue is probably not with the
v.Character.HumanoidRootPart.CFrame = workspace.playertpspawn.CFrame
but with the
for function, it just does not run.
I just resolved it, the code with the player variables ran before even players loaded, so the table was empty. Moving ~~~~~~~~~~~~~~~~~ local playersS = game:GetService("Players") local players = playersS:GetChildren() ~~~~~~~~~~~~~~~~~ to the function fixed the issue