Teleport to position on touched

I am trying to make a part which teleports you to a position once it is touched by the players character.

There are no occurring errors so I am confused with what to do.

I have tried different ways for the part to tell if it has been touched but I think the issue is within the Vector3.new part.

Here is my localscript:

local part = script.Parent
local player = game.Players.LocalPlayer
part.Touched:connect(function(hit)

	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

	if plr then

		player.Character:MoveTo(Vector3.new(-1164.383, 1.5, 499.175)
			
		)

	end

end)

Thank you!

–Make sure this is a script inside a brick

local part = script.Parent
local teleport_to = part.CFrame

part.Touched:Connect(function(object)
	if object:FindFirstAncestorWhichIsA("Model") then
		if object.Parent:FindFirstChild("Humanoid") then
			--found player
			local RealPlayer = game.Players:GetPlayerFromCharacter(object.Parent)
			print(RealPlayer.Name)
			
			--tp player to any point
			object.Parent:PivotTo(teleport_to)
		end
	end
end)
2 Likes