Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Not tp'ing players if touched?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

This script is suppose to tp anyone to 1,1,1 if touched a part

script.Parent.Touched:connect(function(hit)

        local Player = game.Player.PlayerAdded

        Player.Character:MoveTo(Vector3.new(1,1,1))

end)



1 answer

Log in to vote
1
Answered by 8 years ago
script.Parent.Touched:connect(function(hit)
for i,v in pairs(game.Players:GetChildren()) do
if v.Character then
       v.Character:MoveTo(Vector3.new(1,1,1))
end
end
end)

When you reference it you only referenced the hit which is an object. To get all the players in the server we use game.Players:GetChildren() then we use a for i,v in pairs to go thru all of them.

Ad

Answer this question