Remote event is duplicating for each player in game

I have a remote event that fires a number to the server, and then the server adds that value to a single players leaderstat value.

It only adds the value to one player, yet it duplicates for each player in the game. For example, I have it set to send 5 to the Server, but then the server adds 10 if there are two players, 15 if there are three players, etc.

Why would this be occuring? Please help!

On the client, it looks like this

game.ReplicatedStorage.CurrencyChange:FireServer(5)

On the server, it looks like this

game.Players.PlayerAdded:Connect(function(player)
game.ReplicatedStorage.CurrencyChange.OnServerEvent:Connect(function(player, amount)
		player.leaderstats.Points.Value = player.leaderstats.Points.Value + amount 
    end)
end)

player parameter is just the same, so it will cause some bugs. Also remove the RemoteEvent Event from the PlayerAdded.

1 Like

Your Putting your Remote event INSIDE a Player added event, this makes it so that the Event will run for each player, no matter what.

Your code should be

game.Players.PlayerAdded:Connect(function(player)

end)

game.ReplicatedStorage.CurrencyChange.OnServerEvent:Connect(function(player, amount)
	player.leaderstats.Points.Value = player.leaderstats.Points.Value + amount 
end)
1 Like

Awesome thanks that fixed the bug completely

1 Like