Hey, guys. So I've been working on this Gui that shows the player's avatar picture when they join the game by finding their userId. It works great; but that's not the problem.
You see, when I played as a Guest, I noticed that there was no avatar picture - it was just a picture with an X. This means that Guests do not have userIds correct?
I'm not so sure, but I made a TextLabel that had the word"Guest" on it appear whenever the userId of the player couldn't be found; but it's not working...
This is the script inside the TextLabel (It is a localscript):
local button = script.Parent local userid = script.Parent.Parent.Parent.Parent.Parent.userId -- (The parenting here is correct!) if userid == nil then button.Visible = true end
I think I'm trying to veer into a completely different direction, but could anyone please explain to me how to accomplish this? THANKS!
If the starting of the Name is
If the Player's userId property is a
There are multiple ways of checking if the Player is a Guest, but, I have only listed two.
For the code, we will require the following codes:
The if Statement
Now, with all this in mind, let us write the code;
local button = script.Parent --From the original code; Variable 'button' is identifying the Script's Parent local plr = game.Players.LocalPlayer --Variable 'plr' is now identifying the 'LocalScript''s Client if plr.userId <= -1 or plr.Name:sub(1,6) == "Guest " then --The code here is checking if the Player's 'userId' property is less than or equal to '-1', or, if the Player's Name/String Characters between '1-6' is 'Guest ' [Real Guest use Spaces in their names, fake ones don't] button.Value = true --If the Player is a real 'Guest', then it will set the 'button''s 'Visible' property to true, making the GUI appear/Visible to the Client end --This ends the chunk to the 'if' statement
Hope this helped!