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

How can I subtract a value from two Integers?

Asked by 8 years ago

First off I'm making a money script. Example: 1$ 10ยข I'm wondering if I can subtract a value from two integers, allow me to explain. Example: A = 100 B = 10 Say I want to subtract 105 from A could I make A = 0 and subtract 5 from B to get the full value? Result: A = 0 B = 5

Would I need a load of "if" statements or what? Been racking my brain at this for a few days. I know I could probably use NumberValue but it doesn't seem very adaptable for future products that way.

Thank you for the support.

0
I understand what you're asking, and it's very possible. You'll probably only need 2 if statements, however you have not shown real effort, only asking for a script. Shawnyg 4330 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Do an if statement to check if the values negative. Here's an example,

local intvalue = -1 --this would be the value of the intvalue you're checking
if intvalue < 0 then
   intvalue = 0
end

If the intvalue is a negative it will make it 0. I think that's what you were asking. Good luck!

0
I'm more so asking if the Value is greater than the integer I'm subtracting could the int go into a negative and another integer level the int back out to 0 with it's value? CosmicFury 10 — 8y
1
I don't quite know what you're asking. Sorry ): User#11440 120 — 8y
Ad

Answer this question