Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way I can disable a script and enable it again using a different script?

Asked by 3 years ago

There is a property in scripts called disabled that stops your script from working when you enable it in studio, but i cant seem to figure out how to enable it with a script. If I could figure it out I could use it to fix one of the major bugs in my game. Thanks!

0
Are you asking how to enable a script through another one? If so then put script.Disabled = false in the other script that will enable it AntoninFearless 622 — 3y
0
ive tried this in the past but it was with a more complex script, i will try again and update you WheatMealLoaf -2 — 3y
1
it worked! tysm! WheatMealLoaf -2 — 3y
0
Please edit your post and put [SOLVED] in the title to mark it as solved. Benbebop 1049 — 3y

1 answer

Log in to vote
0
Answered by
2Loos 168
3 years ago

Yeah, that's easy! Disabled is a boolean value under local and normal scripts (notice this can't be done with module scripts!) Sample code:

local NEWSCRIPT = Instance.new("Script")
NEWSCRIPT.Parent = game.Workspace
NEWSCRIPT.Name = script
while true do
NEWSCRIPT.Disabled = true --Changed the Bool to true
print('Script was disabled, won't work until disabled is false.')
wait(10)
NEWSCRIPT.Disabled = false --Changed the Bool to false
print('Script was enabled, will work until disabled is checked to true!')
end

Hope this helps! Best regards, 2Loos. :)

Ad

Answer this question