Help with sending server event info

Im tryna sent the vote over through a serer event but I dont wanna create multiple events for every vote. heres what im tryna do. Is this possible?
server script:

game.ReplicatedStorage.MapVote.OnServerEvent:Connect(function(TestMap,TowersMap)
	if TestMap then
		print("TestMapVoted")
	end
	if TowersMap then
		print("Towers Map Voted")
	end
end)

Local script:

script.Parent.Activated:Connect(function(TowersMap)
	local TowersMap
end)

Just loop through each of the buttons and create a connection for each one. Ensure the button has a unique identifier somehow, like a name or a string value inside of it, then send that to the server.

local buttonContainer = script.Parent -- the UI object that contains each button

for i, button in ipairs(buttonContainer:GetChildren()) do
    if button:IsA('GuiButton') then
        button.Activated:Connect(function()
            event:FireServer(button.Name) -- will send the button that is clicked's name to the server
        end)
    end
end

Also note that remote.OnServerEvent’s first argument is the player that fired, then any additional values sent from the client.

2 Likes