Goal
There are 6 GUI buttons. I want to have one RemoteEvent fired to the server when a player clicks on one of the 6 buttons, in order to create a ServerEvent when one of the 6 buttons is clicked.
Issue
Passing on information using the script below has not worked for me. I know why.
Button.Name cannot be accessed by the server.
Localscript:
for _, Button in pairs(ButtonGroup) do
Button.MouseButton1Click:Connect(function()
local ButtonName = Button.Name
print(ButtonName)
ChosenRemote:FireServer(Player, ButtonName)
print("Sent")
end)
end
Topic Question / Alternative?
Is there another way for the server to know which button is clicked by the player?
In the past I used 6 different remotes, but I feel like using one remote is better.
Other tried solutions
I came across a few posts on the forum that had a similar question, however, these did not answer my question. I have tried several hours to make this work.
Cause when you send an Event, your client Player is always the first paremeter, you don’t need to send it yourself.
Change it to that:
for _, Button in pairs(ButtonGroup) do
Button.MouseButton1Click:Connect(function()
local ButtonName = Button.Name
print(ButtonName)
ChosenRemote:FireServer(ButtonName)
print("Sent")
end)
end