Teleporting not working

I am trying to teleport players between two places in my game. When using either my scripts or ones I grabbed from the toolbox to compare to mine, the teleporter doesn’t work and I get the following error in output:

Here is the script:

function Touch(hit) 
	if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true 
	local Pos = script.Parent.Parent:findFirstChild(Teleport)
		hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end Function.
script.Parent.Touched:connect(Touch)

Any ideas what I am doing wrong?

PS: I have also tried lentillacs teleporters and the same error is produced.

2 Likes

I’m not sure if this is right but shouldn’t the “m” in :moveTo() be capitalized?

1 Like

It looks like hit.Parent is equal to an accessory in this case, instead of the player character. To ensure that you are using MoveTo() on a character, you can add this check.

if hit.Parent:FindFirstChild('HumanoidRootPart') then
1 Like
local Cooldown = 5
local Destination = Pos.CFrame


local dbg = true
script.Parent.Touch:Connect(function(t)
	if dbg then
		dbg = false
		local Player = game.Players:GetPlayerFromCharacter(t.Parent)
		local PlayerCharacter = nil
		if Player ~= nil then
			PlayerCharacter = t.Parent
			if PlayerCharacter:FindFirstChild("HumanoidRootPart") ~= nil then
				PlayerCharacter["HumanoidRootPart"].CFrame = Destination
			end
		end
		wait(Cooldown)
		dbg = true
	end
end)
1 Like

yeah you need to add an exception for the Accessories that may be on the characters.

if(not hit.Parent:IsA("Accessory")) then

1 Like

Do hit.Parent.Parent.Humanoid:MoveTo()

1 Like

yeah basically, but what if it doesn’t hit an accessory? then your just grabbing a nil from workspace. (humanoid)

1 Like

Here’s a model that has the issue: Easy Teleporter - Roblox

These are the teleporters by @Lentilkac58

1 Like