✓ Accepted answer
There is, what I'd do is start with a localscript, now, when the player clicks the surface gui, fire to the server like so.
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Event:FireServer(ARGUMENTS HERE)
end)
Now that that is out of the way, create a server script, can be anywhere so long as the server can recognize it when the Event is called
Inside of that script, create the Event and then print the player's name which is always the FIRST ARGUMENT in the event
game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player,ARGUMENTS)
print(player.Name.." has clicked the surfacegui!")
end)
Now, due to this being in the server, this goes for ALL people in game, so in theory, if you wanted to change the surfacegui's Textlabel 's text to the player who clicked the button's name, all you'd need to do is.
game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player,ARGUMENTS)
<Surfacegui destination>..TextLabel.Text = player.Name
end)
In another example, you could FireAllClients so everyone's client can see the player who cloicked the textbutton as well.
But since you are stating that this is a surface gui, I'll assume that you won't need to FireAllClients so I'll leave it at that considering unlike a player's screengui that is on a client side only, you can change a Surfacegui through the server.
3 comments
I apologize for the terrible examples however, I misread your question just a tad bit. But my answer still stands. It should be quite easy to tweak that setup to fix your little problem.
heres what I put for the local script: script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Parent.Parent.OwnerFilter:FireServer() end) the button1click event wont fire, I even tried just having it print something after clicking the button but it wont even do that.
I decided to just use a clickdetector to filter out player names. its not as compact as I would have wanted it to be but oh well.