How to make a variable in an event a global variable?

I have a variable inside of an event and I want to make it global. How do I do this?

Example:

Button.MouseButton1Click:Connect(function()
	local ChildrenOfButton = Button:GetChildren()
	return ChildrenOfButton
end)

ChildrenOfButton.Visible = true

--I know it's not that good of an example, but how would I use ChildrenOfButton outside of the event?

Declare the variable outside of the event but don’t assign it a value.

local ChildrenOfButton;

Can you make an example using my already made script?

local ChildrenOfButton;
Button.MouseButton1Click:Connect(function()
	ChildrenOfButton = Button:GetChildren()
end)

ChildrenOfButton.Visible = true

--I know it's not that good of an example, but how would I use ChildrenOfButton outside of the event?
1 Like

Ah, thank you so much, and sorry, I’m still kind of new to scripting