Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this print the player's name?

Asked by 4 years ago

So I was troubleshooting in my game currently in development and decided to try to print the player's name in a localscript.

https://gyazo.com/f4b95fcc6a3bceee9c09adcaed39ffc9

Nothing prints in the output, not even 'nil' or an error.

0
Where's the script located, is there any infinite yields in the output? Nickuhhhhhhhhhhhhhhh 834 — 4y
0
There is an infinite yield, is that a problem? Also the script is located in StarterPlayerScripts. JGBlocky 9 — 4y
0
So this is the infinite yield except I think it's irrelevant since it's talking about the character line https://gyazo.com/11e190e9177250b4595621e83dfdf1ee JGBlocky 9 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Character isn't a valid Instance of a Player, it's actually a property. And what you are doing is waiting for a child named "Character" to exist inside the Player. You would have to do Player.Character, but since you call that before the character actually loads, you can do a simple condition written below.

local Character = Player.Character or Player.CharacterAdded:Wait()
0
But the character and humanoid lines aren't really relevant to the print line not working, sorry if I was unclear about that, thanks for the tip though. Would you happen to know why the print isn't working? JGBlocky 9 — 4y
0
It's because you are using WaitForChild which is constantly yielding the rest of your code since the Character will never be a valid member of the Player. Nickuhhhhhhhhhhhhhhh 834 — 4y
0
Ohhhh I understand now thanks JGBlocky 9 — 4y
Ad

Answer this question