I'm trying to make a map voting system that uses remote events to get what the player votes for. But for example, if there are 3 players in the game, the server will receive the event 3 times.
Server Script:
script.MapVoting:FireAllClients(MapsGot) script.MapVoting.OnServerEvent:Connect(function(Player, VotedMap) print("Event received") -- Prints by how many people are in the game for i,v in pairs(script.MapVotes:GetChildren()) do if v.Name == VotedMap then v.Value = v.Value + 1 break end end end)
Local Script:
game.Workspace.RoundController.MapVoting.OnClientEvent:Connect(function(MapTable) script.Parent.Frame.Map1.Map1.MouseButton1Click:Connect(function() print("Fire Server") -- Prints only once game.Workspace.RoundController.MapVoting:FireServer(MapTable[1].Name) end) script.Parent.Frame.Map2.Map1.MouseButton1Click:Connect(function() game.Workspace.RoundController.MapVoting:FireServer(MapTable[2].Name) end) script.Parent.Frame.Map3.Map1.MouseButton1Click:Connect(function() game.Workspace.RoundController.MapVoting:FireServer(MapTable[3].Name) end) end)
Why does this happen? I've tried using debounces on both the server and the client but the problem isn't fixed. Thanks!
whoopsie daisy i put the onserverevent function inside a player added function :p