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

Simple question : Why is my variable not taking away the number?

local m = m - 1000

My variable is not taking away the number. I know this is a simple fix but i tried everything and it doesn't work. Thank you.

1 answer

✓ Accepted answer

well you cant do local m = m - 1000 because the variable m is just being declared.. at run time, the statement actually looks like this m = nil - 1000.. so if variable m in m - 1000 was not declared before using it, it should through an error that says attempt to do arithmetic on global m(a nil value or something like that. or sometimes the code will just halt when it reaches that statement.

i recommend doing it like this:

local x = 500 --whatever number you want
local m = x - 1000

the above should work fine b/c x is declared before used, so the statement won't look like this on run time m = nil - 1000

6 comments

0

it was already decal

0

*declared

0

It just been declared, so m don't has any value.

1

in that case then do m = m - 1000 and not local m = m - 1000

0

Thanks. It worked.

0

np

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