function PlayerHelper:SetFacingDirection(player: Player)
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local direction = game.Workspace.Lobby.Pirate.WorldPivot.Position
humanoidRootPart.Parent.Humanoid.AutoRotate = false
local newCFrame = CFrame.lookAt(humanoidRootPart.Position, direction)
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position, direction)
end
end
I’m thinking that the chararter position must be an event that is triggered after the PlayerAdded event do you know what the last event that is trigger is?
Okay I have found the solution.
Thanks to those that tried to help, its really appreciated.
My problem seems to be that an event that faces the players direction gets triggered after the CharaterAdded event.
I was able to add a local script to StarterCharacterScripts. I can add a local script in here and it will trigger every time the player respawns and after the CharaterAdded event. A local script is valid in this case as it’s something to make a players life easier and make the game feels nicer.
local character = game.Players.LocalPlayer.Character
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local direction = Vector3.new(51.277935, 289.530121, 3218.95288)
--uncomment the below line if you want the charater to be locked to the direction you set
--humanoidRootPart.Parent.Humanoid.AutoRotate = false
humanoidRootPart.CFrame = CFrame.lookAt(humanoidRootPart.Position, direction)
Its worth noting that the docs says this about StarterCharacterScripts
The StarterCharacterScripts class stores scripts to be parented in a player’s Player.Character, when they spawn. Unlike scripts stored in the PlayerScripts folder, these scripts will not persist when the player respawns.
I took that to mean that after they were run once they were destroyed. That is not the case. every time a character is added they are run again…maybe it means it is run once for each time a character is added