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

What is wrong with this teleport script?

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 comment

1

Hmm, I think it may be line 14, can you CFrame a torso?

3 answers

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

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)

1 comment

0

Edit to how it meets your needs.

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)

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