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

How to get a players username when they click a surfaceGUI text button?

Asked by 2 years ago
Edited 2 years ago

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)

1 answer

Log in to vote
0
Answered by 2 years ago

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

Answer this question