Im trying to get the players username when they click a surfaceGUI textButton in a server script.
My code: ** FIXED MYSELF **
local button = script.Parent local inUse = game.Workspace.Booth1:WaitForChild("InUse") local Owner = game.Workspace.Booth1:WaitForChild("Owner") button.MouseButton1Click:Connect(function() if inUse.Value == false then inUse.Value = true Owner.Value = ("Players username") -- players username here ^^^^^^^^^^^ print("Claimed!") else print("Already being used!") end 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.
local button = script.Parent local inUse = game.Workspace.Booth1:WaitForChild("InUse") local Owner = game.Workspace.Booth1:WaitForChild("Owner") button.MouseClick:Connect(function(player) if inUse.Value == false then inUse.Value = true Owner.Value = (player.Name) print(player.Name .. " pressed me!") print("Claimed!") else print("Already being used!") end end)