The title explains it all. Here’s my code:
local players = game:GetService("Players")
local player = players.LocalPlayer
print(player.Name)
local character = player.Character
print(character)
Here’s the output:
What did I do wrong?
The title explains it all. Here’s my code:
local players = game:GetService("Players")
local player = players.LocalPlayer
print(player.Name)
local character = player.Character
print(character)
Here’s the output:
What did I do wrong?
Try replacing
local character = player.Character
With
local character = player.Character or player.CharacterAdded:Wait()
Probably because the script loads faster than the player’s character
Here’s the solution as mentioned above:
local character = player.Character or player.CharacterAdded:Wait()
The “or” basically checks if the first thing you are looking for is nil or not. So in this case the script loads faster than the character resulting in the first attempt being nil, so it goes to the second part and waits for the character.
lmk if this helped. GL!
Thank you! What I can assume happened is that the character didnt load in time!
Yep.
type or paste code here
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.