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

How can I subtract a value from two Integers?

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.

1 comment

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.

1 answer

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!

2 comments

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?

1

I don't quite know what you're asking. Sorry ):

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