User profile picture & Name on Surface GUI

Hiya!

I would need help with setting up a register system! I can’t figure out how could I add user’s Roblox profile picture and username on this SurfaceGui!

For example, players clicks log in, it will start counting time and just says register is taken. I would like to change that text to the user who logged in (their Roblox username) and at the same time, small profile picture as a Image Label or something to appear on SurfaceGui as well. Current code is super simple, but not sure how to make something I just described! :slight_smile:

Name should appear in that “Username” box and Profile picture on the right side of the screen!

I really hope someone can help me out with this one!

Have a nice day!

CURRENT CODE:

Code
taken = false

function yo()
	if taken == false then
		taken = true
	script.Parent.Text = "LOGGED IN"
	script.Parent.Parent.playerlabel.Text = "REGISTER TALEN"
	stime = 600
	for i=1,600 do
		stime = stime - 1
		script.Parent.Parent.timelabel.Text = stime
		wait(1)
	end
	stime = 600
	script.Parent.Text = "LOGIN"
	script.Parent.Parent.playerlabel.Text = "NO USER"
	taken = false
	else
		
	end
end

script.Parent.MouseButton1Click:connect(yo)
Summary

This text will be hidden

Adding a username should be quite simple. For this to work properly, add an invisible block with a clickdetector over the “Click to start shift” button. You will now be able to grab the player info as well as rank lock it with a clickdetector. Basically, move the code above to inside the brick and change the bottom line to:

script.Parent.ClickDetector.MouseClick:Connect(yo)

The rest should be self explanatory, you have to alter the code to change the locations of the gui parts.
To get the player’s username, this should be pretty simple. The first argument returned from a clickdetector is the player instance you can find in the players section in the explorer.
To retrieve this, change the function line to:

function yo(plr)

This means you can simply make the username box display their username using the following:

--plr is the argument from the clickdetector
usernamelabel.Text = plr.Username
--OR you can use this (there is no difference between the two):
usernamelabel.Text = plr.Name

Then, for the profile picture, please check out this thread’s solution. Make sure the profile picture goes on an ImageLabel. Im not really good with getting profile pictures using code.

Hope this helps.

1 Like