I found some code on the devforum that I was gonna use and it works, but I don’t quite understand what this line of code is doing.
local Character = Player.Character or Player.CharacterAdded:Wait()
I get the Player.Character part but that usually would error because the player’s character isn’t loaded yet. Does or Player.CharacterAdded:Wait() somehow fix this?
In my view . It is because a script run very fast. when the script run . This line Player.Character will search for character in player and if it is not found it will give error . Player.CharacterAdded:Wait() will wait until character is added to player
basically it checks to see if the character exists using Player.Character
if there is a character then the variable is equal to that character
if there isn’t a character then Player.CharacterAdded:Wait() runs
it basically waits until the character is added, and then it returns the character
since it returns the character, the variable is equal to that character