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

[SOLVED!] Why does my points-per-second go up as players swim?

Asked by 4 years ago
Edited 4 years ago

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.

0
show your script bud SoftlockedUnderZero 668 — 4y
0
Sorry, I didn't even think of that. MaximussDev 86 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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. :)

Ad

Answer this question