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

How do I teleport all players to a certain area when one player clicks a brick?

Asked by 3 years ago

I have no idea where to start! Any help would be great!

I tried doing

 script.Parent.MouseClick:Connect(function(player)
for i, v in pairs(game.Players:GetChildren()) do
v.Position = Vector3.new(3,3,3)

1 answer

Log in to vote
0
Answered by 3 years ago

A person's player is kind of like the information about them, but what you actually see in the world is their character. You can get a player's character with player.Character, and you can teleport the character by changing the position of the HumanoidRootPart

script.Parent.MouseClick:Connect(function(player)
for i, v in pairs(game.Players:GetChildren()) do
    if v.Character then -- make sure the player has a character so that it won't crash the script if they are respawning or something
        v.Character.HumanoidRootPart.Position = Vector3.new(3, 3, 3)
    end
end
0
Ohhh so I am supposed to check if there is a character first? SmellyCarlover 12 — 3y
0
typically yeah, and "if v.Character" is just a shorter way of writing 'if v.Character ~= nil" OfficerBrah 494 — 3y
0
Thanks guys! SmellyCarlover 12 — 3y
Ad

Answer this question