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

How come my friend and I got teleported when I clicked the brick?

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)

5 comments

0

I can't tell you whats wrong with the script, but I can tell you an easier way of doing it: Use moveTo()

0

Its because you didn't specify a certain player. I made you a script in your last post that only teleports the clicker.

0

Use a code block or ~85% of us won't bother reading it(me included)

0

Sorry im new to all of this @lukeb50

0

@project Can you do it again please

1 answer

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.

2 comments

1

Thank you so much!!!!

0

No problem.

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