Hello im trying to make a stat system for my game. Everything works and scales great its just ive been running into a bug. For every person in the server, when i put in my stats it increases by 1. So if their is 2 people ill get 2+ if theirs 3 ill get 3+. This also takes away 3 points from the user so its not duping but it means its firing multiple times and idk why. Ive put print commands and i see that it prints 2 of the prints when theirs 2 people, but the print doesnt say x2 and the end it just prints separately for some reason.
2 person Server
https://gyazo.com/2f098c95a1783cd262516e054e0f981f
3 Person Server
https://gyazo.com/4a374a06a25b99f37bbc937eb53ea09d
Script
game.ReplicatedStorage.Stats.HpButton.OnServerEvent:Connect(function(Player)
local Stats = Player:WaitForChild(“Stats”)
local Parent = script.Parent
local EndB = Parent:WaitForChild(“Endurance”)
local Points = Stats:WaitForChild(“Points”)
if Points.Value > 0 then
game.ReplicatedStorage.GUIRemotes.EnoughPoints:FireClient(Player)
print(“FireOnce”)
Stats:WaitForChild(“MaxHealth”).Value = Stats:WaitForChild(“MaxHealth”).Value + 5
Points.Value = Points.Value - 1
else
game.ReplicatedStorage.GUIRemotes.NotEnough:FireClient(Player)
end
end)
game.ReplicatedStorage.Stats.StaminaButton.OnServerEvent:Connect(function(Player)
local Stats = Player:WaitForChild(“Stats”)
local Parent = script.Parent
local EndB = Parent:WaitForChild(“Stamina”)
local Points = Stats:WaitForChild(“Points”)
if Points.Value > 0 then
if Stats:WaitForChild(“Stamina”).Value < 1999 then
game.ReplicatedStorage.GUIRemotes.EnoughPoints:FireClient(Player)
Stats:WaitForChild(“Stamina”).Value = Stats:WaitForChild(“Stamina”).Value + 1
Points.Value = Points.Value - 1
else
game.ReplicatedStorage.GUIRemotes.NotEnough:FireClient(Player)
end
end
end)
game.ReplicatedStorage.Stats.StrengthButton.OnServerEvent:Connect(function(Player)
local Stats = Player:WaitForChild(“Stats”)
local Parent = script.Parent
local EndB = Parent:WaitForChild(“Strength”)
local Points = Stats:WaitForChild(“Points”)
if Points.Value > 0 then
game.ReplicatedStorage.GUIRemotes.EnoughPoints:FireClient(Player)
Stats:WaitForChild(“Strength”).Value = Stats:WaitForChild(“Strength”).Value + 2
Points.Value = Points.Value - 1
else
game.ReplicatedStorage.GUIRemotes.NotEnough:FireClient(Player)
end
end)