✓ Accepted answer
ClickDetectors fire the MouseClick event which returns the Player. You can't exactly use a LocalScript, since anyone can click the button at any given moment. For the parameter for the function, you'd set the Player variable. On your line 7, you were setting the text equal to an Object, which is impossible. You need to add .Value. Here is your script fixed up, with more organization (Normal script):
script.Parent.Parent.Parent.ClickDetector.MouseClick:connect(function(Player)
script.Parent.Text = Player.userId
end)
The use of those variables wasn't needed, unless you were using them in another script as well. If that's the case, then:
script.Parent.Parent.Parent.ClickDetector.MouseClick:connect(function(Player)
script.Parent.Parent.Parent.USERID.Value = Player.userId
script.Parent.Text = Player.userId
end)
3 comments
Omg thank you!, i just got a question, why is it (function(Player), you aren't defining Player anywhere?
@iNicklas, As I said in my question, the parameter within the function, is set as the variable for the Player. It can be anything. 'Noob', 'Abc', but it will always equal the player who clicked it.
Oh, thats quite smart. ill keep that notified :)