Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

2 comments

0

put print statements in every mousebutton1click function to see if all of them are being activated by one mouseclick

0

I did and they are not

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.