Basic IntValue subtraction issues

Working on this FNAF game for my friend, here’s the issue:

– I need to subtract the total battery percent by a number every 6 seconds
– I also need to preform some simple equations on the number, such as adding multipliers, like doors and lights adding up on consumption rates.

But at the minimum, I just need to subtract an IntValue.

Here’s my code, it’s a server script.

local l1 = script.Parent.Parent.Parent.Light1.SpotLight.Enabled
local l = script.Parent.Parent.Parent.Light.SpotLight.Enabled

--^^ light variables ^^--

local lev1 = script.Parent.Parent.Level1
local lev2 = script.Parent.Parent.Level2
local lev3 = script.Parent.Parent.Level3
local lev4 = script.Parent.Parent.Level4

--^^ level variables ^^--

while wait(1) do
	local lm = script.Parent.light_multiplier.Value
	local cr = script.Parent.consumption_rate.Value
	local dm = script.Parent.door_multiplier.Value
	local bc = script.Parent.battery_current.Value
	local tcm = dm + lm
	bc = bc - 1
	if bc > 70 and bc < 100 or bc == 100 then
		lev1.Transparency = 0
		lev2.Transparency = 0.7
		lev3.Transparency = 0.7
		lev4.Transparency = 0.7
	elseif bc > 40 and bc < 70 or bc == 70 then
		
		lev1.Transparency = 0.7
		lev2.Transparency = 0
		lev3.Transparency = 0.7
		lev4.Transparency = 0.7
	elseif bc > 10 and bc < 40 or bc == 40 then
		lev1.Transparency = 0.7
		lev2.Transparency = 0.7
		lev3.Transparency = 0
		lev4.Transparency = 0.7
	elseif bc > 0 or bc == 0 and bc < 10 or bc == 10 then
		lev1.Transparency = 0.7
		lev2.Transparency = 0.7
		lev3.Transparency = 0.7
		lev4.Transparency = 0
end
	if bc < 0 then
		bc = 0
	end
	if bc == 0 then
		l1 = false
		l = false
	end
end

Yes, I know my code isn’t practical in any way, shape, or form, sorry, I’ve heard it about 1000 times now and I’d rather not get comments about how its unconventional.

Try using

local l1 = script.Parent.Parent.Parent.Light1.SpotLight.Enabled
local l = script.Parent.Parent.Parent.Light.SpotLight.Enabled

--^^ light variables ^^--

local lev1 = script.Parent.Parent.Level1
local lev2 = script.Parent.Parent.Level2
local lev3 = script.Parent.Parent.Level3
local lev4 = script.Parent.Parent.Level4

--^^ level variables ^^--

while wait(1) do
	local lm = script.Parent.light_multiplier
	local cr = script.Parent.consumption_rate
	local dm = script.Parent.door_multiplier
	local bc = script.Parent.battery_current
	local tcm = dm.Value + lm.Value
	bc.Value = bc.Value - 1
	if bc.Value > 70 and bc.Value< 100 or bc.Value == 100 then
		lev1.Transparency = 0
		lev2.Transparency = 0.7
		lev3.Transparency = 0.7
		lev4.Transparency = 0.7
	elseif bc.Value > 40 and bc.Value < 70 or bc.Value == 70 then
		
		lev1.Transparency = 0.7
		lev2.Transparency = 0
		lev3.Transparency = 0.7
		lev4.Transparency = 0.7
	elseif bc.Value > 10 and bc.Value < 40 or bc.Value == 40 then
		lev1.Transparency = 0.7
		lev2.Transparency = 0.7
		lev3.Transparency = 0
		lev4.Transparency = 0.7
	elseif bc.Value > 0 or bc.Value == 0 and bc < 10 or bc.Value == 10 then
		lev1.Transparency = 0.7
		lev2.Transparency = 0.7
		lev3.Transparency = 0.7
		lev4.Transparency = 0
end
	if bc.Value < 0 then
		bc = 0
	end
	if bc.Value == 0 then
		l1 = false
		l = false
	end
end

I have had this problem before and this may or may not work.

Huh, it works, thank you so much!