Faczki
(Faczki)
July 20, 2021, 1:03am
#1
Basically i have this script
game.Players.PlayerAdded:Connect(function(plr)
print(plr.Name)
print(plr.Character.Name)
end)
I just changed it to a print()
for testing but it results in the same error:
attempt to index nil with 'Name'
I have always used plr.Character
and it always worked so i’m not sure why it’s not now.
Note:
print(plr.Name)
Is working fine
1 Like
Could it be an issue with loading, what I mean is does the character have time to load before it tried to read the name? Could you fix the by like doing a waitforchild or something.
1 Like
Faczki
(Faczki)
July 20, 2021, 1:07am
#3
Well i can try that but technically the player.Character
is not inside the plr
instance.
1 Like
Yes but you still have to wait for the character instance to spawn. The player instance like happens before the character spawns in to the game.
That would then make sense why the print(plr.Name) works cuz it is faster then the character itself to spawn
2 Likes
SOTR654
(SOTR654)
July 20, 2021, 1:10am
#5
As the player character still does not load, it gives nil, this will take or wait for the player character
game.Players.PlayerAdded:Connect(function(plr)
print(plr.Name)
local Character = plr.Character or plr.CharacterAdded:Wait()
print(Character.Name)
end)
3 Likes