Script is not enabling

Hello, everyone!

I’ve been making a Minigame place and have a script for each minigame and a main script. Each minigame script is disabled and when the main script picks a random minigame, it fails to enable the script. Let me show you some of my code:

local num = math.random(1,5)
for i, v in pairs(game.ReplicatedStorage.Minigames:GetChildren()) do
     if v:IsA(“Script”) then
         Game:ReplicatedStorage.Minigames:GetChildren()[num].Disabled = false
         print(“game.ReplicatedStorage.Minigames:GetChildren()[num].name”)
         break
    end
end

I’m not getting any error messages and the minigame name is only printing once (from the server script). It should be printing twice because in each minigame script I am printing the name of the minigame. So the problem is that the script isn’t enabling when it should be. Here is the minigame scripts (the scripts that aren’t enabling) for those who need it:

-- Sword Fight
 script.Disabled = true
 print(“Sword Fight Chosen”) -- This part is different for each script/minigame.

Thanks for any help! If you have any questions, I’ll be happy to answer.

Disabling/enabling a script mid-game is a bad practice, and it comes with a bunch of problems. I would recommend that you create a module script for each minigame, and then call the main function of the module’s when you want to start a certain minigame.

1 Like

disabing a script from a script disables the whole script, it’s not printing because the script is disabled before it reaches the print

This is what I thought the problem was. I was originally going to use module scripts but I then used normal scripts just to test how it would work.
Thanks for the help!

1 Like