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

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

Asked by 7 years ago
Edited 7 years ago

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.

01local teleportbrick1 = workspace:WaitForChild("TeleportBrick1")
02local teleportbrick2 = workspace:WaitForChild("TeleportBrick2")
03 
04local waittime = 3
05local touched = false
06 
07local function teleport(position)
08    return function(hit)
09        if not touched then
10            touched = true
11            local character = game.Players:GetPlayerFromCharacter(hit.Parent).Character
12            local head = character and character:FindFirstChild("Head")
13            if head then
14                head.CFrame = position
15            end
View all 23 lines...
0
Usually, when making a debounce, you make a variable, not a bool value for it. hiimgoodpack 2009 — 7y
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. mrsbigballz 8 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

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:

1part = script.Parent
2tp = game.Workspace.tp2
3 
4part.Touched:connect(function(hit)
5if hit.Parent.Humanoid then
6hit.Parent.Torso.CFrame = CFrame.new(tp.CFrame.X, tp.CFrame.Y, tp.CFrame.Z)
7end
8end)

The above is an example that should work.

0
Could I just use the exact position of the part? aka CFrame.new(100, 100, 100)? mrsbigballz 8 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
01-- Untested, try this script..
02local PartToTouch = script.Parent -- if you touch that certain part
03PartToTouch.Touched:connect(function()
04local GoTo = game.worskpace.TeleportPart -- First off all change that to the part u wanna teleport to
05 
06local char = game:GetService("Players").LocalPlayer:GetCharacter() -- get the players character
07local torso = char.Torso -- get the players torso
08 
09torso.Position = Goto.Position + Vector3.new(0,10,0)
10end)

I guess this will work

Answer this question