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

How can you deincerement a number in a value?

I'm making a button when clicked it deincerements a number by 1. I attempted to make the following:

game.ReplicatedStorage.PokeBall.Value = -1

But it changed the physical value to "-1".

Much appreciated if you can answer! YourFriendlyNeighbor

1 answer

✓ Accepted answer

To decrement a variable, you should do something like this:

Variable = Variable - Value

In your specific case, this would be:

game.ReplicatedStorage.PokeBall.Value = game.ReplicatedStorage.PokeBall.Value - 1

This works by setting the variable (in your case game.ReplicatedStorage.PokeBall.Value) to the value it already has, minus the number to decrement by (in this case -1).

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