So I found a script for when I click the brick it teleports me to the other brick. When my friend joined and i clicked it and he was still spawning in it teleported him with me. Can someone tell me how to make it so only the person who click the brick gets teleported please.
This is the script im using:
function onClicked()
local c = game.Players:GetChildren() for i = 1, #c do c[i].Character.Torso.CFrame = CFrame.new(script.Parent.Parent.block2.Position)--change "block2" to the name of the object you want to be teled to... end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
That script is returning a table of all players in-game, and when that is used it teleports all the players in the game. I'll fix it for you.
script.Parent.ClickDetector.MouseClick:Connect(function(p) p.Character:MoveTo(script.Parent.Parent.block2.Position) end)
When the block is clicked, the script teleports the player's character to the position of block2.