Hello, I was starting to learn how to script in my Roblox game and after fixing all the syntax errors I got onto trying to fix the Unknown global errors but cannot figure out how to fix them.
1 | local ModuleScript = { } |
2 | mt = getrawmetatable(game) |
3 | make_writeable(mt) |
4 | local old = mt.__namecall |
5 |
6 | mt.__namecall = newcclosure( function (self,...) |
7 | local args = { ... } |
^^^ Thats all the code that has caused this error.
Usually, the error leads to unknown variable names or function calls the script doesn't recognize. Take these examples:
variable typo
1 | local food = 100 --full hunger!! |
2 |
3 | if fod = = 100 then --fod is not defined and so it leads to the W001 unknown global error |
4 | print ( "not hungry." ) |
5 | end |
function call typo
01 | local function Eat() |
02 | food + = 15 |
03 | end |
04 |
05 | script.Parent.Activated:Connect( function () |
06 | if food = = 100 then |
07 | return false |
08 | elseif food > 100 then |
09 | food = 100 |
10 | return false |
11 | elseif food < 100 then |
12 | Et() --Et() isn't defined so it leads to the W001 unknown global error |
13 | end |
14 | end ) |
Make sure to look through your scripts for typos, but also incorrect function calls. In this case you've probably typed in a function that is incorrect.
Here is a Roblox Dev Hub page upon Metatables.
https://developer.roblox.com/en-us/articles/Metatables
Hope this helped!