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

local a = workspace.VisitorEntrance.Door:GetChildren()

for i=1,#a do
	wait()
	if a[i].ClassName == 'Part' or a[i].ClassName == "UnionOperation" then
	local b = Instance.new("NumberValue")
	b.Parent = a[i]
	b.Name = "Transp"
	b.Value = a[i].Transparency
	end
end

function _G.VisitorOpen()
	for i=1,#a do
		a[i].Transparency = 1
		a[i].CanCollide = false
	end
end


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".

1 comment

0

is it possiblr to not make the doors with _G if it is uneccessary yet hard?