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

My click teleport teleports everyone?

So I added a part where it would check which player clicks it but that hasn't any effect

function onClicked()

local c = game.Players:GetChildren() -- I think its here where it goes wrong
for i = 1, #c do 
c[i].Character.Torso.CFrame = CFrame.new(script.Parent.Parent.TP99.Position)--Name of object where u get tpd to
end 

end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)

function onClicked(player) -- but I added this so it would tp the person who clicks it but it still teleports all
    player.Character.Torso.CFrame = CFrame.new(script.Parent.Parent.TP99.Position)
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)


2 comments

0

The first function loops through the c table(which is a table of all players in the game) and teleports everyone in that table. Remove that function. The second function looks to work

0

use game.Players:GetPlayers()

1 answer

✓ Accepted answer

*Replace * local c = game.Players:GetChildren() -- I think its here where it goes wrong With **local c = game.Players:GetChild() -- I think its here where it goes wrong **

2 comments

0

oh lmao really?

0

I have it another way at this moment and it works too but will do it that way then, thanks

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