Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

3 comments

0

Where's the script located, is there any infinite yields in the output?

0

There is an infinite yield, is that a problem? Also the script is located in StarterPlayerScripts.

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

1 answer

✓ Accepted answer

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()

3 comments

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?

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.

0

Ohhhh I understand now thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.