Help with Proximity Prompt doors that teleport the player to a declared part's position

Pretty sure I’ve scripted this correctly but its meant to teleport the player to a part’s position when the certain one of two proximity prompts are triggered (proximity prompt 1 and 2 have different designated parts to teleport to) but instead its teleporting the player to a random position near centre of the map

I’m unsure if there may be a correlation between this and a camera system because theres a camera system that forced the camera in a specific angle based on the orientation of a part anchored in the workspace and whenever the proximity prompt is triggered the player is teleported near it

My Code


local prompt1 = script.Parent.TeleportDoors.Door1.Door1Prompt

local prompt2 = script.Parent.TeleportDoors.Door2.Door2Prompt

local pospart1 = script.Parent.TeleportParts.TeleportPos1

local pospart2 = script.Parent.TeleportParts.TeleportPos2

prompt1.Triggered:Connect(function(player)

print("Prompt1 Triggered")

player.Character.HumanoidRootPart.CFrame=CFrame.new(Vector3.new(pospart2.Position))

end)

prompt2.Triggered:Connect(function(player)

print("Prompt2 Triggered")

player.Character.HumanoidRootPart.CFrame=CFrame.new(Vector3.new(pospart1.Position))

end)
2 Likes

Instead of CFrame.new(Vector3.new(pospart2.Position)) just use CFrame.new(pospart2.Position)

1 Like

Use humanoid:moveto() it’s way easier but all it requires is a part. Not position

Doesn’t this just make the character walk? Not teleport

local HRP = player.Character:FindFirstChild(“HumanoidRootPart”)
local Part = game.Workspace:FindFirstChild(“Part”)
if HRP and Part then
HRP.Position = Part.Position
end

Oh, I meant character:moveto().

local prompt1 = script.Parent.TeleportDoors.Door1.Door1Prompt
local prompt2 = script.Parent.TeleportDoors.Door2.Door2Prompt
local pospart1 = script.Parent.TeleportParts.TeleportPos1
local pospart2 = script.Parent.TeleportParts.TeleportPos2

prompt1.Triggered:Connect(function(player)
	local character = player:WaitForChild("Character")
	local HRP = character:WaitForChild("HumanoidRootPart")
	HRP.CFrame = CFrame.new(pospart2.Position)
end)

prompt2.Triggered:Connect(function(player)
	local character = player:WaitForChild("Character")
	local HRP = character:WaitForChild("HumanoidRootPart")
	HRP.CFrame = CFrame.new(pospart1.Position)
end)