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

My teleport brick doesn't work but gives no error?

I have a teleporter that I'm trying to make that sends you to a shop in my game. The problem is the brick I'm trying to make it teleport you to also sends you back. I've added a debounce to make sure players can't infinity get teleported between the two bricks. I've tried this script and it doesn't teleport you like I'm trying to make it do and there's error in output. If anyone has a clue as to why this doesn't work, that would be awesome.

local teleportbrick1 = workspace:WaitForChild("TeleportBrick1")
local teleportbrick2 = workspace:WaitForChild("TeleportBrick2")

local waittime = 3
local touched = false

local function teleport(position)
	return function(hit)
		if not touched then
			touched = true
			local character = game.Players:GetPlayerFromCharacter(hit.Parent).Character
			local head = character and character:FindFirstChild("Head")
			if head then
				head.CFrame = position
			end
			wait(waittime)
			touched = false
		end
	end
end

teleportbrick1.Touched:connect(teleport(CFrame.new(61.5, 70.7, -123.5)))
teleportbrick1.Touched:connect(teleport(CFrame.new(-69.5, 15.6, -44.5)))

2 comments

0

Usually, when making a debounce, you make a variable, not a bool value for it.

0

I understand that, but if I use a debounce it will instantly teleport the player back after they were teleported to the shop because it's a two way teleporter.

2 answers

Hi.

:MoveTo() is meant to walk the player to that location.

If you're looking to teleport you should change the CFrame to the torso to the new position.

A small example:

part = script.Parent
tp = game.Workspace.tp2

part.Touched:connect(function(hit)
if hit.Parent.Humanoid then
hit.Parent.Torso.CFrame = CFrame.new(tp.CFrame.X, tp.CFrame.Y, tp.CFrame.Z)
end
end)

The above is an example that should work.

1 comment

0

Could I just use the exact position of the part? aka CFrame.new(100, 100, 100)?

-- Untested, try this script..
local PartToTouch = script.Parent -- if you touch that certain part
PartToTouch.Touched:connect(function()
local GoTo = game.worskpace.TeleportPart -- First off all change that to the part u wanna teleport to

local char = game:GetService("Players").LocalPlayer:GetCharacter() -- get the players character
local torso = char.Torso -- get the players torso

torso.Position = Goto.Position + Vector3.new(0,10,0)
end)

I guess this will work

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