How to make a LocalScript re-enable itself when its Disabled property changes

While true do is very uneffcient don’t use that. It would lag your game.

What do you think about coroutine? It would check if it is disabled or not.

As long as you include a wait (even wait() could work), and you aren’t doing anything performance-intensive, you should be ok.
Alternatively you could use RunService.Stepped:Connect or Heartbeat.

How is a coroutine done? I’ve never really tried such thing before.

I tried RunService.Stepped and RunService.Heartbeat too, they did not work sadly.

@jsnotlout1 Sadly it ended up not working, which is quite disappointing, I’ll be looking for more solutions.

1 Like

You basically use it like a function.
coroutine.wrap(function()

end)

Coroutines allow multiple things to run at the same time basically.

I’d recommend doing what :GetPropertyChangedSignal inside of the most important local script in the game, so that if the exploiters do try to disable it, it will get reenabled and at the same time, if they disable that script, the game won’t work properly.

I tried this and unfortunately it did not work, basically it did not re-enable itself.

This method didn’t work either unfortunately.

As I said, do it inside of a different more important or just very important local script.

Oh, apologies, I missed that part of the message. Although it’d be a great feature if ROBLOX were to implement a system where specific scripts up to the developer’s choice, are not able to be disabled.

Yeah, we can use it for an localscript.

Coroutine did not worked for me too.

Make it separate scripts??? You can’t make it re-enable itself if it cant run anything.

I found a pretty disgusting way to achieve this using threads, it also takes destroying into consideration:

task.spawn(function()
	local clone = script:Clone() 
	local old_parent = script.Parent

	while task.wait(.1) do 
		if not script.Parent then
			local new = clone:Clone()
			new.Parent = old_parent 
			break
		elseif script.Disabled then 
			script.Disabled = false 
			break
		end
	end
end)
5 Likes

How long has this solution existed? I’m surprised I’m just now finding out about it.

another local script with the disabled script as its parent that waits on the .Changed event

script.Parent.Changed:Connect(function()
   print(script.Parent.Disabled)
end)

This solution is the one, it works surprisingly perfectly, and I’m surprised nobody’s ever shared it to the public, thank you so much.

1 Like

Just to make sure, this works pretty much the same with coroutines, right?