Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is remote event being fired by how many players are in the game?

Asked by 4 years ago
Edited 4 years ago

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!

0
put print statements in every mousebutton1click function to see if all of them are being activated by one mouseclick Code1400 75 — 4y
0
I did and they are not WaddelsG 69 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

whoopsie daisy i put the onserverevent function inside a player added function :p

Ad

Answer this question