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

Why wont my character teleport from one part to the next?

Essentially, the way this script works is it will teleport your character to a certain part(oPart) when the part in question(Script.Parent) is touched. For some reason however, it will not teleport.

local Teleport = "oPart" --Part your teleporting to
function Touch(hit)
    local Pos = script.Parent.Parent:findFirstChild(Teleport)
        hit.Parent:moveTo(Pos.Position) 
 end
script.Parent.Touched:connect(Touch)

1 answer

✓ Accepted answer

The script looks ok so I can only assume that your findFirstChild is failing to find the part oPart. In this case it should be better to store the parts position when the code is ran and also you should include a check to make sure that it is a player character.

Example:-

-- location to the part may need WaitForChild
local tpPartPosition = workspace.Part2.Position
local plrServ = game:GetService("Players")

script.Parent.Touched:Connect(function(hit)
	--check for players only
	if plrServ:GetPlayerFromCharacter(hit.Parent) then
		hit.Parent:MoveTo(tpPartPosition)
	end
end)

Hope this helps

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