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

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

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

✓ Accepted answer

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

3 comments

0

Ohhh so I am supposed to check if there is a character first?

0

typically yeah, and "if v.Character" is just a shorter way of writing 'if v.Character ~= nil"

0

Thanks guys!

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