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

How do you make that when you touch a brick you teleport to a another brick?

Asked by
goodlead -62
3 years ago

I am trying to teleport players from one brick the other brick. Can anyone help out?

1 answer

Log in to vote
1
Answered by
Roger111 347 Moderation Voter
3 years ago
Edited 3 years ago

Here is an example of touching a teleport part:

--[[
You will also need to have some setup before putting this script in your place. You can do it however you would like, but with MY setup I have 2 parts in my workspace. One is called "Part1" and the other is called "Part2" and my script will work if you setup like this.
]]
local part1 = workspace:WaitForChild("Part1")
local part2 = workspace:WaitForChild("Part2")

local debounceTable = {}
--[[
debounceTable is used to keep track of the player that
just teleported, and makes sure they're able to get off
before being teleported again. (So they don't get telep
-orted back and forth and can't get off)
]]

--This detects if the touching object is a player for part1
part1.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and table.find(debounceTable,hit.Parent) == nil then
        table.insert(debounceTable,hit.Parent)
        hit.Parent:MoveTo(part2.Position)
        wait(2)
        table.remove(debounceTable,table.find(debounceTable,hit.Parent))
    end
end)
--This detects if the touching object is a player for part2
part2.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and table.find(debounceTable,hit.Parent) == nil then
        table.insert(debounceTable,hit.Parent)
        hit.Parent:MoveTo(part1.Position)
        wait(2)
        table.remove(debounceTable,table.find(debounceTable,hit.Parent))
    end
end)

Try this page next time! (And make sure to hit "View Source" if you're going to copy my code)

1
Thank you very much!! goodlead -62 — 3y
0
no prob Roger111 347 — 3y
1
Also you joined roblox a long time ago in 2008!!! goodlead -62 — 3y
Ad

Answer this question