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

What is wrong with this teleport script?

Asked by
JJ_B 250 Moderation Voter
10 years ago

I have a click detector and a Vector3Value in the parent. This script should teleport you to the coordinates of the vector3value:

DestinationPos = script.Parent.TeleportTo.Value

print("Teleport Script loaded") 

local Door = script.Parent

function onClicked(hit) 
    print("Teleport Hit") 
    local human = hit.Parent:findFirstChild("Humanoid") 
    if (human ~= nil ) then 
        -- a human has touched this teleport! 
        print("Human touched teleport") 
            -- Change the values in this next line to where you want it 2 teleport you to.
                        hit.Parent.Torso.CFrame = CFrame.new(DestinationPos)
    end 
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked) 
1
Hmm, I think it may be line 14, can you CFrame a torso? Shaydesilva 85 — 10y

3 answers

Log in to vote
0
Answered by
HexC3D 830 Moderation Voter
10 years ago

Just put a brick on where you want to teleport make the Transparency to 1 and cancollide and just copy the position.

hit.Parent.Torso.CFrame = CFrame.new() -- Position of the brick,mk
Ad
Log in to vote
0
Answered by 10 years ago

Use 2 bricks and put this inside one of them

script.Parent.Touched:connect(function(t)
    if t.Parent:FindFirstChild("Humanoid") and t.Parent:FindFirstChild("HumanoidRootPart") then
    t.Parent:MoveTo(game.Workspace["NameOfTeleportHere"].Position)
    end
end)
0
Edit to how it meets your needs. fireboltofdeath 635 — 10y
Log in to vote
0
Answered by
RFL890 4
3 years ago
local val = Vector3.new(coords)
local door = door -- for example script.Parent.Door


door.Touched:Connect(function(hit)
       if hit.Parent:FindFirstChild("Humanoid") then
               hit.Parent.HumanoidRootPart.CFrame = CFrame.new(val)
        end
 end)

Answer this question