How the global variables works?
I wanted to make doors with _G but I don't even know how it works.
01 | local a = workspace.VisitorEntrance.Door:GetChildren() |
05 | if a [ i ] .ClassName = = 'Part' or a [ i ] .ClassName = = "UnionOperation" then |
06 | local b = Instance.new( "NumberValue" ) |
09 | b.Value = a [ i ] .Transparency |
13 | function _G.VisitorOpen() |
16 | a [ i ] .CanCollide = false |
21 | script.Parent.ClickDetector.MouseClick:Connect(_G.VisitorOpen) |
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".