Im trying to get the players username when they click a surfaceGUI textButton in a server script.
My code: ** FIXED MYSELF **
01 | local button = script.Parent |
02 | local inUse = game.Workspace.Booth 1 :WaitForChild( "InUse" ) |
03 | local Owner = game.Workspace.Booth 1 :WaitForChild( "Owner" ) |
04 |
05 |
06 |
07 |
08 | button.MouseButton 1 Click:Connect( function () |
09 |
10 | if inUse.Value = = false then |
11 | inUse.Value = true |
12 | Owner.Value = ( "Players username" ) |
13 | -- players username here ^^^^^^^^^^^ |
14 |
15 | print ( "Claimed!" ) |
16 | else |
17 | print ( "Already being used!" ) |
18 |
19 | end |
20 | end ) |
I just fixed this myself. Instead of using a textbutton I used a ClickDetector inside the part and then put this script inside of it.
01 | local button = script.Parent |
02 | local inUse = game.Workspace.Booth 1 :WaitForChild( "InUse" ) |
03 | local Owner = game.Workspace.Booth 1 :WaitForChild( "Owner" ) |
04 |
05 |
06 |
07 | button.MouseClick:Connect( function (player) |
08 |
09 | if inUse.Value = = false then |
10 | inUse.Value = true |
11 | Owner.Value = (player.Name) |
12 | print (player.Name .. " pressed me!" ) |
13 |
14 |
15 | print ( "Claimed!" ) |
16 | else |
17 | print ( "Already being used!" ) |
18 |
19 | end |
20 | end ) |