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

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

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.

2 comments

0

show your script bud

0

Sorry, I didn't even think of that.

1 answer

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

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