Skinstashery
Roblox
Home / Roblox / Studio script library / Teleport pad
RB-004

Roblox teleport pad script

Two pads: stand on one and you appear on the other.

Script type
Script
Where it goes
Inside each pad Part
Category
Hazards and pads

For your own game in Roblox Studio. Not for use in other people's games.

The code

-- Teleport pad. Use one copy of this Script in each of the two pads.
-- Pad A has TARGET_NAME = "PadB". Pad B has TARGET_NAME = "PadA".

local TARGET_NAME = "PadB"   -- name of the OTHER pad (it must be in the Workspace)
local COOLDOWN = 3           -- seconds before the same player can teleport again
local EXTRA_HEIGHT = 3       -- studs above the target pad to land

local Players = game:GetService("Players")

local pad = script.Parent
local target = workspace:WaitForChild(TARGET_NAME)

pad.Touched:Connect(function(hit)
	local character = hit.Parent
	local player = Players:GetPlayerFromCharacter(character)
	if not player then
		return
	end

	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid or humanoid.Health <= 0 then
		return
	end

	-- The cooldown is saved on the player, so both pads share it.
	-- This stops you being sent straight back when you land.
	local blockedUntil = player:GetAttribute("TeleportBlockedUntil") or 0
	if os.clock() < blockedUntil then
		return
	end
	player:SetAttribute("TeleportBlockedUntil", os.clock() + COOLDOWN)

	character:PivotTo(target.CFrame + Vector3.new(0, target.Size.Y / 2 + EXTRA_HEIGHT, 0))
end)

How to set it up

  1. Insert two Parts in the Workspace. Rename one to PadA and the other to PadB.
  2. Add a Script inside PadA. Paste the code and set TARGET_NAME to "PadB".
  3. Add a Script inside PadB. Paste the same code and set TARGET_NAME to "PadA".
  4. Play. Walk onto PadA and you should land on PadB.

Change it

More in Hazards and pads

All Roblox scripts

More Roblox tools