Get all scripts in a folder and Enable/Disable them all

Hi, this is an oddly specific issue, I know, but I’d like to know if there is a way to do what the title says.

I have a folder with all my scripts in it, yeah?
image

In a script in the main menu I am using I added these 2 lines:

local scriptsFolder = game.Players.LocalPlayer.Character:WaitForChild("Scripts")
local scripts = scriptsFolder:GetChildren()

I tried a few things to enable/disable them with code all at once, but I can’t figure out how to. If it helps, the scripts are supposed to enable once the main menu is destroyed, which happens after the Play button is pressed.

Any help is appreciated

1 Like

You could just loop through all of the children inside of the folder with a for loop and for each children disable them with the propriety they have.

For example:

local scriptsFolder = game.Players.LocalPlayer.Character:WaitForChild("Scripts")

for i, v in pairs(scriptsFolder:GetChildren()) do
	if v:IsA("Script") then
		v.Enabled = false
	end
end

This code would just need to be run whenever you want all the scripts to be disabled.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.