How would I go about merging the deplete() function into the fuel() function where it calls for the deplete() function to run in line 6?
local fuelFull = true
local started = false
function fuel()
if fuelFull == true and started == false then
deplete()
print 'STARTING DEPLETING'
elseif fuelFull == false then
print 'EMPTY'
end
end
function deplete()
started = true
print 'DEPLETING'
while true do
script.Parent.FuelValue.Value = script.Parent.FuelValue.Value -1
wait (.1)
if script.Parent.FuelValue.Value <15 and script.Parent.FuelValue.Value >0 then
print 'LOW FUEL'
elseif script.Parent.FuelValue.Value >15 and script.Parent.FuelValue.Value >0 then
print 'SAFE'
elseif script.Parent.FuelValue.Value <15 and script.Parent.FuelValue.Value >-1 then
print 'EMPTY'
fuelFull = false
started = false
end
end
end
script.Parent.Touched:connect(fuel)

2 comments
Have you tested this? It looks fine to me.
I have tested it withing a much, much larger script and something about it being in two different functions causes a part of the larger script to partially break.