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

How do you re-enable a disabled script?

Asked by 5 years ago

I made it so that a script would be disabled when the tool it is in is unequipped. What would you do to re-enable the script? I tried script.Parent.Enabled = true but it didn't work.

Tool = script.Parent.Parent.Parent

Tool.Equipped:connect(function()
    script.Parent.Enabled = true
end)

Any help? I'm not sure what else to do. I disabled the parent of this script, and now I'm trying to re-enable it when the tool is selected. The tool is the parent of the parent of this script.

0
Scripts don't have an Enabled property, they have a Disabled property - also this setup might be finicky in that you have it disabled when the game starts up. SummerEquinox 643 — 5y
0
Oh, it only disables the first time you equip and tunequip the item. Wiredfpz 2 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Enabled is not a property of a script, the actual name for it is Disabled. It's as simple as doing this:

script.Parent.Disabled = true
-- Some code later...
script.Parent.Disabled = not script.Parent.Disabled -- or script.Parent.Disabled = false

If you have any questions, please ask them.

Ad

Answer this question