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

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

Asked by 6 years ago

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)

0
I can't tell you whats wrong with the script, but I can tell you an easier way of doing it: Use moveTo() dogs253 -4 — 6y
0
Its because you didn't specify a certain player. I made you a script in your last post that only teleports the clicker. ProjectJager 62 — 6y
0
Use a code block or ~85% of us won't bother reading it(me included) lukeb50 631 — 6y
0
Sorry im new to all of this @lukeb50 Shaletsgo 8 — 6y
0
@project Can you do it again please Shaletsgo 8 — 6y

1 answer

Log in to vote
0
Answered by
CodyDev 70
6 years ago

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.

1
Thank you so much!!!! Shaletsgo 8 — 6y
0
No problem. CodyDev 70 — 6y
Ad

Answer this question