Hey everyone!
So, I've been doing some things, and I just can't break this bug.
Basically, in my game, players swim to gain points, which can be used to purchase boosters/buffs. However, when players swim for a while, this will happen:
For, let's say ten seconds, the points-per-second is normal, at 10. At 10 seconds and later, it will go up by a large amount each second.
My partner was AFKing in-game when he came back to see he'd made four million points. This is insanely large, and I don't want it to do that.
Script:
function Starter.GainWaterPoints(level) local debounce = false while script.Parent.InPool.Value == true do if debounce == false then game.Players:GetPlayerFromCharacter(script.Parent.Owner.Value).leaderstats["Water Points"].Value = (game.Players:GetPlayerFromCharacter(script.Parent.Owner.Value).leaderstats["Water Points"].Value + math.floor(game.ReplicatedStorage.WaterPointsSettings.WaterPointsPerSecond.Value * game.Players:GetPlayerFromCharacter(script.Parent.Owner.Value).HiddenStats.Boost.Value)) * level debounce = true wait(1) debounce = false end wait(1) end end
Any help is appreciated!
Regards, MaximussDev.
Found the issue.
If you look in my script, you'll find this line of code:
game.Players:GetPlayerFromCharacter(script.Parent.Owner.Value).leaderstats["Water Points"].Value = (game.Players:GetPlayerFromCharacter(script.Parent.Owner.Value).leaderstats["Water Points"].Value + math.floor(game.ReplicatedStorage.WaterPointsSettings.WaterPointsPerSecond.Value * game.Players:GetPlayerFromCharacter(script.Parent.Owner.Value).HiddenStats.Boost.Value)) * level
I was actually multiplying the player's current points value as well as the boost multiplier. :)