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

Unknown error when trying to call a function?

total = nil

function tax(percent,num)
total = num * percent
end

tax(0.5,1255) -- line which errors

Output:

21:29:34.173 - No method name passed in __namecall for Object

I have no idea why this is happening. I tried this in the output itself and it worked, but when i try using it through a script it just calls out that error.

Help would be appreciated, this is really frustrating.

1 answer

✓ Accepted answer

Not sure where you put the script.. When I put it into the server script service it worked fine.. Test the below in a script in the server script service. Don't use a local script.

total = nil
 
function tax(percent,num)
total = num * percent
return total
end
 
print(tax(0.5,1255))

2 comments

0

Total should be defined inside the function as a local. It's rather unorganized to just have random variable names floating around in your main scope, and can potentially lead to hidden issues later on.

0

True you should generally define variables as local

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