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

My regeneration script won't run?

Asked by 4 years ago
Edited 4 years ago

It regenerates, but it never disables itself

model = script.Parent.Parent
local thing = script.Parent:WaitForChild("Value")

backup = model:clone()

thing.Value = "Yes"

function regenerate()

    model = backup:clone()
    model.Parent = game.Workspace
    model:makeJoints()

    thing.Value = "No"
    script.Parent.BrickColor = BrickColor.new(26)
    wait(30)
    script.Parent.BrickColor = BrickColor.new(104)
    thing.Value = "Yes"
end

function onHit(hit)
    if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and thing.Value == "Yes" then
        regenerate()
    end
end

script.Parent.Touched:connect(onHit)
0
You already have a variable that deals with this called "enabled." Instead of setting script.Disabled in the script, can you try setting enabled to false, then set it to true? y3_th 176 — 4y
0
The minute you disable a script, it's threads cancel; meaning it no-longer runs. You'll have to enable it manually or via another program. Instead, as suggested by @y3_th, set enabled to False to create a proper debounce. Ziffixture 6913 — 4y
0
Updated it, still wont work TheExtraDip 19 — 4y

Answer this question