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

What is wrong with my MetaTable Arguments?

I'm trying to make a simple equation solver, and I get the following error:

  • Workspace.Script:6: attempt to call local 'A' (a number value)

"A" is a Number Value since I placed numbers only as Arguments. What am I doing wrong? Any and all help is appreciated.

local Equation = {
	C = 0;
}

function Equation.SolveForC(A,x,B,y)
	Equation.C = A(x) + B(y)
	print(Equation.C)
end

Equation.SolveForC(2,3,2,3)

4 comments

0

Your problem is A(x). Lua treats this as a function call, when you actually want to multiply. Instead, do "Equiation.C = Ax + By"

0

Why do you always post comments instead of answers, GoldenPhysics?

0

They're shorter.

0

There are no metatables involved here

1 answer

✓ Accepted answer

The answer is simple: You did not use correct Lua formatting for multiplication. In Lua, it is only ever x * y, never x(y) or y(x). Here is the corrected code:

local Equation = {
    C = 0;
}

function Equation.SolveForC(A,x,B,y)
    Equation.C = A*x + B*y
    print(Equation.C)
end

Equation.SolveForC(2,3,2,3)

If this helped, please accept this answer.

2 comments

0

Thank you so much!

0

You're welcome!

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