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

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

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

1 answer

✓ Accepted answer

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)

3 comments

1

Thank you very much!!

0

no prob

1

Also you joined roblox a long time ago in 2008!!!

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