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

How the global variables works?

Asked by
zeptak 4
6 years ago

I wanted to make doors with _G but I don't even know how it works.

01local a = workspace.VisitorEntrance.Door:GetChildren()
02 
03for i=1,#a do
04    wait()
05    if a[i].ClassName == 'Part' or a[i].ClassName == "UnionOperation" then
06    local b = Instance.new("NumberValue")
07    b.Parent = a[i]
08    b.Name = "Transp"
09    b.Value = a[i].Transparency
10    end
11end
12 
13function _G.VisitorOpen()
14    for i=1,#a do
15        a[i].Transparency = 1
View all 21 lines...

The script normally works but when I make another script where is to run _G.VisitorOpen() Then it prints "Attempt to call a nil value".

0
is it possiblr to not make the doors with _G if it is uneccessary yet hard? TheluaBanana 946 — 6y

Answer this question