Repair factory system

Oh lol wait you right, i wrote something strange xd

No errors now in output finallly

It’s seems what it’s don’t detect CD(click detector), bec value doesn’t change

Uhmm still can’t figure problem

Okay, nevermind i’m stupid, but when value is false again, script don’t start that script again

Okay i found a stupid way to fix that script lol

You should bring the clickdetecter event and the function outside of the while loop. And put it between local RandomNumber = 0 and while FactoryBrokenValue.Value == false do. I guess.

I already fixed that so everything works, thank you anyways

Okay i can’t detect if value changes, how do i rework that to detect if value changed?
script:

local MoneyLevel = script.Parent.Parent.Parent.MoneyLevel
local SpeedLevel = script.Parent.Parent.Parent.SpeedLevel
local MainPart = script.Parent.Parent.MainPart
local FactoryBrokenValue = script.Parent.Parent.FactoryBroken
local DB = true
	if MoneyLevel.Value == 0 then
		if SpeedLevel.Value == 0 then
			while FactoryBrokenValue.Value == false do
				wait(0.8)
				script.Parent.Position = Vector3.new(42.434, 10.85, -335.235)
				local PlrBricks = script.Parent.Parent.Parent.PlayerBricks
				PlrBricks.Value = PlrBricks.Value + 1
				script.Parent.Anchored = true
				script.Parent.Transparency = 1
				wait(3)
				script.Parent.Anchored = false
				script.Parent.Transparency = 0
			end
		end
	end
	
	if SpeedLevel.Value == 1 then
		if MoneyLevel.Value == 0 then
			while FactoryBrokenValue.Value == false do
				wait(0.8)
				script.Parent.Position = Vector3.new(42.434, 10.85, -335.235)
				local PlrBricks = script.Parent.Parent.Parent.PlayerBricks
				PlrBricks.Value = PlrBricks.Value + 1
				script.Parent.Anchored = true
				script.Parent.Transparency = 1
				wait(2)
				script.Parent.Anchored = false
				script.Parent.Transparency = 0
			end
		end
	end
	if SpeedLevel.Value == 1 then
		if MoneyLevel.Value == 1 then
			while FactoryBrokenValue.Value == false do
				wait(0.8)
				script.Parent.Position = Vector3.new(42.434, 10.85, -335.235)
				local PlrBricks = script.Parent.Parent.Parent.PlayerBricks
				PlrBricks.Value = PlrBricks.Value + 2
				script.Parent.Anchored = true
				script.Parent.Transparency = 1
				wait(2)
				script.Parent.Anchored = false
				script.Parent.Transparency = 0
			end
		end
	end

You can use a valueobject’s Changed event to detect the value has changed

I know that, but where do i put that?

I don’t get what your script is doing, but I’m pretty sure that MoneyLevel and SpeedLevel Detection only run once at the beginning. If you want to refresh and detect them upon a value has changed, just pack 6th line to the end of the code in this:

ValueObject.Changed:Connect(function()
  --Detection code(Code of checking MoneyLevel and SpeedLevel)
end)