Does Script.Disabled not even work?

So I am working on a Fire system, and to stop the spread of fire I utilised script.Enabled. However, peculiarly code still ran even when script.Enabled was false. I read that for some reason, it is not a replicated variable. So I used script.Disabled, but code still runs serverside perfectly fine when script.Disabled = true! Even when eliminating the client portion of the system, code just doesn’t turn off unless I destroy the script or otherwise halt the thread. Why??

	if math.random(1,3) == 3 then
		part:breakJoints()
		wait(math.random(3,10))
		part.CanCollide = false
	end
script.Disabled = true
--code shouldn't work anymore, right?

-- if the player touches fire, they get burned. This should stop after it finishes burning though, because then the script would be disabled.
part.Touched:Connect(function(otherpart)
	if debounce == false and otherpart.Parent:FindFirstChild('Humanoid') and not otherpart.Parent:FindFirstChild('HumBurn') then
		local burn = script.HumBurn:Clone()
		burn.Parent = otherpart.Parent
		burn.Enabled = true
end
end)

Disabling the script doesn’t stop all the threads and stuff. You need to script a proper deactivation system, which you should be doing anyways to guarantee safe exit of whatever your script is doing.

So I should make my own variable for Disabled, and then just check everytime it’s touched. That works, but It’s still quite stupid that Disabling doesn’t do anything. What even is the point of .Enabled and .Disabled then?

You Can do this:

script:Remove()

script:Destroy()

script.Enabled = false (New Script Disable)

script.Disabled = true

The Code shouldnt anymore, The Script has been disable, therefore put out of commission until Enabled Once again by another Script

We’ve already established neither .Disabled nor .Enabled work and destroying the script is not optimal.

Edit: Run the code for yourself, .Disabled nor .Enabled actually halt the script, which is the issue. I should just make a variable and check it everytime it tries to set something on fire. Pretty stupid though.

Usually, when you want to disable the Code, Maybe Try this?

local TouchEnabled = true

if math.random(1,3) == 3 then
		part:breakJoints()
		wait(math.random(3,10))
		part.CanCollide = false
	end
TouchEnabled = false
script.Enabled = false


if TouchEnabled = true then
part.Touched:Connect(function(otherpart)
	if debounce == false and otherpart.Parent:FindFirstChild('Humanoid') and not otherpart.Parent:FindFirstChild('HumBurn') then
		local burn = script.HumBurn:Clone()
		burn.Parent = otherpart.Parent
		burn.Enabled = true
end
end)

end


if not an if statement, try a while loop

Yes that works, Thanks. I solved this earlier by doing practically the same thing with a variable “enabled”, but i’ll give you the solution because you elegantly wrote it out.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.