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

Wont let me add or subtract?

Asked by 9 years ago

Says error on line 2, Not sure what i did wrong.

function Add(A, B)
print(a - b)
return a + b
end

function Subtract(A, B)
print(a - b)
return a - b
end

Add(53, 42)
Subtract(21, 11)

2 answers

Log in to vote
3
Answered by 9 years ago

Read this, I cooked it up for you just now.

function Add(A, B) --Your function.
    -- Roblox is case sensitive so you have to use Capital A, and Capital B. Instead of a + b. SINCE you used Capital A & Capital B as variables when the funcion is called.
    print(A + B)
    return A + B
end

function Subtract(A, B)
    -- Roblox is case sensitive so you have to use Capital A, and Capital B. Instead of a - b. SINCE you used Capital A & Capital B as variables when the funcion is called.
    print(A - B)
    return A - B
end

Add(Variable1, Variable2)
Subtract(Variable1, Variable2)
Add(Subtract(53, 12), 12) -- Since your function uses return you could also do something like that :P.
Ad
Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

All identifiers, properties, and keywords are case-sensitive. That means the capitalization counts.

a is not the same thing as A -- they are completely different variables!

Answer this question