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

Is there a way to prevent leaderstats going down?

I've wanted to make a script which the player's leaderstats can only go up, and if it goes down, it'll go back to the original value. I just wanted to know what I can use and where I can start...

1 comment

0

.Changed event, operators, and if else statements.

1 answer

Using GetPropertyChangedSignal you can compare both the new and old values and work accordingly. If the new value is less than the old, set the value to the old.

local lastValue = statistic.Value
statistic:GetPropertyChangedSignal("Value"):connect(function()
	if (statistic.Value < lastValue) then
		statistic.Value = lastValue
		return 
	end
	lastValue = statistic.Value
end)

2 comments

0

So... is this a Local Script or a Script? Where do I put this...

0

obviously a server script.... set statistic = to the IntValue/NumberValue you want to track

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