Re-abling a script not working

Hey! I have a script trying to re-enable a script yet it does not work for some reason.
The script is shown as enabled but for some reason the code inside it doesn’t run at all. Would anyone be able to help?

2 Likes

Could we have a bit more context?

Important things to know:

  1. Have you tried a print statement in the other script (the one being enabled)

  2. Is the script enabling the other script a local script?

1 Like

Yes i’ve done so, and no, the script enabling it is a server script too

For the Script that you are trying to enable, where is it placed in the game? By default, Scripts with a RunContext of Legacy will only run in certain containers (such as the Workspace and ServerScriptService) and not in storage services, unless you set its RunContext to Server or Client.

And in your reply to @EffBeeCee , you confirmed that you added a print statement into that Script; was the print statement at the very top of the Script or was it contained within a function, loop, etc.?


Also, when the game first starts, does that Script start out by having its Enabled property set to false, or is it turned on and off throughout the course of gameplay?

Are there any repeatable sections of code in the script (e.g. functions) or none at all? If there are no functions / no way of calling the functions after initially running the script, then what could be happening in that case is that all of its code runs and isn’t repeated even after turning it on / off again.

The script is in ServerScriptService.

I had a print statement before the enabling and after the enabling that printed whether the script was enable or not.

When the game starts, the script is set to false.

The script contains a functioned is triggered throughout the player chatting a select sentence.
I know that it is not the problem itself as when i let the game start with the code enable it works perfectly fine.

1 Like

So to clarify further, when the Script is re-enabled, neither the print statements nor the function run at all (or only the print statements run)?

We might need more context about the code from both scripts to figure out what could be causing this, since, from what you’ve mentioned so far about how this is structured, the code within the Script that is being re-enabled should be able to run as intended.

Do you have a print that fires when the other script enables the script that needs to be enabled? Do you know if the script.Enabled = true is even actually running?

1 Like

The prints inside the script re-abling script2 work before and after having enabled script2, but all the prints inside script2 do not work after re-enabling it. No code inside it runs at all even when triggered.

1 Like

Yes, and it prints out “true” meaning that the script gets successfully re-enabled.

1 Like

Would you be able to provide video / screenshots of the Output as well as what the properties of the second Script look like (from the server view while playtesting in Roblox Studio) after the initial Script tried to enable it?

I can’t think of anything else at the moment that would be preventing the code in the second script from running if that second Script is in a place where its code would run by default and if the first Script was actually successful at updating the Enabled property.

are u enabling it client sided or server sided, if client then make it server ( u might have said it somewhere i didnt see )