My script is in a part, and it is supposed to teleport the player that clicks the part to another part called Teleport. For some reason, it teleports every player in the server to Teleport. Can anyone help?
My script -
function onClicked() local c = game.Players:GetChildren() for i = 1, #c do c[i].Character.Torso.CFrame = CFrame.new(script.Parent.Parent.Teleport.Position) end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Actually, it's doing exactly what it was made to do. On line 3, you're going through every player, rather than just the player who clicked it.
script.Parent.ClickDetector.MouseClick:connect(function(plr) -- It has a parameter of the player who clicked! plr.Character.Torso.CFrame = CFrame.new(script.Parent.Parent.Teleport.Position) end)