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 make it so that any brick named One will teleport to Two?

Basically what it says up there . This script works and all but I can only click on one brick named One but not the others also named One.

local clickDetector=workspace["One"]["ClickDetector"]
local function onMouseClick(player)
  workspace.One.Position=workspace.Two.Position
  wait(1) 
  workspace.One["ClickDetector"]:Destroy()
end
clickDetector.MouseClick:connect(onMouseClick)

1 comment

0

it works thanks!!

1 answer

✓ Accepted answer

It's easy. Use loop. Here is corrected code.

for _, i in pairs(game.Workspace:GetChildren()) do
     if i.Name == "One" then
          if i:FindFirstChild("ClickDetector") then
               i.ClickDetector.MouseClick:connect(function()
                    if game.Workspace:FindFirstChild("Two") then
                         i.CFrame = game.Workspace.Two.CFrame
                         i.ClickDetector:Destroy()
                    end
               end)
          end
     end
end

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