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

How do I fix 'W001 Unknown Global *blank*' Errors?

Asked by 4 years ago
Edited 4 years ago

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.

1local ModuleScript = {}
2mt = getrawmetatable(game)
3make_writeable(mt)
4local old = mt.__namecall
5 
6mt.__namecall = newcclosure(function (self,...)
7    local args  = {...}

^^^ Thats all the code that has caused this error.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Usually, the error leads to unknown variable names or function calls the script doesn't recognize. Take these examples:

variable typo

1local food = 100 --full hunger!!
2 
3if fod == 100 then --fod is not defined and so it leads to the W001 unknown global error
4    print("not hungry.")
5end

function call typo

01local function Eat()
02    food += 15
03end
04 
05script.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
14end)

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!

Ad

Answer this question