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)

3 comments

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?

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.

0

Updated it, still wont work