Hello! I want to make the player teleport into the elevator, but the player sometimes teleports outside the model when I use it. Here is my closet script:
-- isPlayerHidingHere is a varible set inside the script
isPlayerHidingHere = not isPlayerHidingHere
script.Parent.Interaction.ProximityPrompt.Enabled = false
if isPlayerHidingHere then
player.Character.HumanoidRootPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.CFrame.Position) * CFrame.Angles(0, script.Parent.TeleportPart.Orientation.Y, 0)
wait(.1)
player.Character:MoveTo(script.Parent.TeleportPart.Position)
player.Character.Humanoid.WalkSpeed = 0
player.data.isHiding.Value = true
playerThatIsHiding = player
else
player.Character:MoveTo(script.Parent.ExitPart.Position)
player.Character.Humanoid.WalkSpeed = 14
player.data.isHiding.Value = false
playerThatIsHiding = nil
end
task.wait(1)
script.Parent.Interaction.ProximityPrompt.Enabled = true
And here is what is happening: