Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
Cyrakohl 108
5 years ago
Edited 5 years ago

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

Answer this question