When a player teleports, I would like for them to face a toward a fixed spot, but I'm not sure how. Is there a way to do this?
This script is to teleport the player to an area when they click a button on a gui. If the solution could be implemented within this script that would be great!
Player = game.Players.LocalPlayer SpawnTo = game.Workspace.SpawnTele TeleportButton = script.Parent.TeleportButton HasPressedTeleport = false function TeleportPlayer() if HasPressedTeleport == false then Player.Character:MoveTo(SpawnTo.Position) wait(0.1) end end TeleportButton.MouseButton1Down:connect(TeleportPlayer)
Using MoveTo isn't the way to do this, all parts will move with the hrp, so just rotate/move the hrp to teleport a player
(HRP = HumanoidRootPart)
For this, use CFrame
Btw, use remote events, don't teleport client side
Player = game.Players.LocalPlayer SpawnTo = game.Workspace.SpawnTele TeleportButton = script.Parent.TeleportButton HasPressedTeleport = false function TeleportPlayer() if HasPressedTeleport == false then local char = Player.Character if char then -- Might not be loaded local HRP = char:WaitForChild('HumanoidRootPart') HRP.CFrame = SpawnTo.CFrame -- You can rotate 'spawnto' to change the players rotation or use cframe angles end end end TeleportButton.MouseButton1Down:connect(TeleportPlayer)
If you have any question, or I made a typo/mistake, just ask :)
So as an edit for your question, the best way to do it is to set the camera quickly to attach, then back to custom
Player = game.Players.LocalPlayer SpawnTo = game.Workspace.SpawnTele TeleportButton = script.Parent.TeleportButton HasPressedTeleport = false local Cam = workspace.CurrentCamera function TeleportPlayer() if HasPressedTeleport == false then local char = Player.Character if char then -- Might not be loaded local HRP = char:WaitForChild('HumanoidRootPart') HRP.CFrame = SpawnTo.CFrame -- You can rotate 'spawnto' to change the players rotation or use cframe angles repeat wait() Cam.CameraType = Enum.CameraType.Attach until Cam.CameraType == Enum.CameraType.Attach repeat wait() Cam.CameraType = Enum.CameraType.Custom until Cam.CameraType == Enum.CameraType.Custom end end end TeleportButton.MouseButton1Down:connect(TeleportPlayer)