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

function(Player) is giving me a number value - why?

Hello, I have a really small but irritating problem.

With this code:

script.Parent.TextButton.MouseButton1Down:Connect(function(Player)
	print(Player)
end)

I get a number value instead of the name of the player who clicked it.

Why?

1 answer

Assuming this is in a local script The MouseButton1Down Event does not return Player and the only person who would be clicking that button is the client the GUI is being displayed on so to get the player you can simply just do this:


local Player = game.Players.LocalPlayer -- This is the client the GUI is being hosted on

script.Parent.TextButton.MouseButton1Down:Connect(function()

print(Player.Name)
end)

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