Finding a players username through a script?

Hello everyone. I need some help trying to find the player’s username through a script? I’m trying to display the players username on a BillBoard GUI when a ClickDetector is clicked. I’m not very good at scripting.

Here is my code so far:

local detector = script.Parent.ClickDetector
local username = -- How do I find this?


detector.MouseClick:Connect(function()
	-- Code will go here.
end)

I am trying to display the username on the “PlayerName” TextLabel after the click detector was clicked. image

Once I know how to find the username, I should be able to find the leaderstats, right?

Any help will be greatly appreciated, thanks!

(Apologise if this is all wrong.)

1 Like

It’s really simple you just have to do this.

detector.MouseClick:Connect(function(player)
	local username = player.Name
end)
4 Likes

Wow! Thanks for your response, it works perfectly.