How do i detect what player clicked a GUI button

Im doing some thing where if a player clicks a button every player respawns and the round restarts, i put a GUI that tells all the players who clicked it, and i want to get the name of the player that clicked it so i can put in the GUI

3 Likes

Since it is a GUI button, you would be using a localscript to handle this input, so you can :FireServer a remote event that notifies all players of this.

How do i get the player that clicked it?

You just fire a remote to the server which in turn fires to all clients.

button.Activated:Connect(function()
    remote:FireServer()
end)

remote.OnClientEvent:Connect(function(message)
    print(message) -- just an example
end)

Then in your server script.

remote.OnServerEvent:Connect(function(player)
    remote:FireAllClients(player.Name .. " clicked the button")
    -- the resetting code down here
end)
5 Likes