Helping to make this only checks when Enabled == true

Hello, i used this script to check if water’s Enabled property has changed to enable a light

local MinIndex = 1
local MaxIndex = 2
local CurrentIn = 0
local Path = script.Parent

for current = MinIndex, MaxIndex do
	CurrentIn = CurrentIn + 1
	local Names = "Mini000"
	if CurrentIn < 10 then
		Names = "Mini00"..CurrentIn
	else
		if CurrentIn < 100 then
			Names = "Mini0"..CurrentIn
		else
			Names = "Mini"..CurrentIn
		end
	end

	local lights = Path[Names].Lighting.Lights
	local WEnabled = Path[Names].Nozzle.WaterEnabled
	local water = Path[Names].Nozzle.Water
	local refill = Path[Names].Nozzle.Refill

	water:GetPropertyChangedSignal("Enabled"):Connect(function()
		if WEnabled.Value == 1 then
			WEnabled.Value = 0
			for _, bulb in ipairs(lights:GetChildren()) do
				if bulb.Name == "bulb" then
					bulb.light.Brightness = 1
					bulb.light.Enabled = true
					bulb.Material = "Neon"
				end
			end
		end
	end)
end

how to make that this part to only checks that when Enabled == true instead of checking both true and false?

water:GetPropertyChangedSignal("Enabled"):Connect(function()`
2 Likes

You could try adding an if statement which checks if water.Enabled == true, and then continue with the script

1 Like

wait a minute i didn’t have thoughts about that, i’ll try that right away, thanks!

1 Like

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