Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[solved] Why wont my script teleport players?

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.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.