How do i make that factory script works properly

  1. What do you want to achieve? Keep it simple and clear!
    I wanna achieve when 1)If factory broken, it’s stop working(most part of script is done), 2) When upgrade happens factory works faster/gives more money.

  2. What is the issue? Include screenshots / videos if possible!
    Issue is: i can’t detect value change, but if i add that thing script won’t work properly, so i have to ask what to do

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tryed to add Value change thing, but this didn’t help

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

FactoryBrokenValue.Changed:Connect(function()
	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
end)
FactoryBrokenValue.Changed:Connect(function()

	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	
	end)
FactoryBrokenValue.Changed:Connect(function()

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
end)

still have no idea how to do that

Okay first problem is fixed, so i know how to do second thanks

what was the solution to the first problem?

it’s not solution alr, bec my sripts lags bec i added very much loops, you can check my new post to understand