-
What do you want to achieve?
I’m trying to make a fuel system for a jetpack, which would subtract the fuel by 10 every second the player has been using it for. and add the fuel back by 10 every 3 seconds. -
What is the issue?
the issue is, when i use the jetpack the fuel would get subtracted by random numbers it would start at 100 then 99, 97,90, 85, 78 until 0 or sometimes less(sometimes it would go over 100 when it’s refueling) I’ve also encountered something wrong with my script the coroutine would play an extra time after it’s yield.
-
What solutions have you tried so far?
YES, I’ve gotten no help i assume i wasn’t clear enough please respond to this post if I’m making no sense here.
this is just the subtracting part of the code i assume the adding part is just the same but just adding it
local fuel = 100
local function drainingFuel()
local drainingFuelC = coroutine.wrap(function()
local i = os.time()
while wait(.5) do
local info1 = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In,0,false,0)
local goals1 = {Size = UDim2.new(fuel/100,0,1,0); }
local Healthup = TweenService:Create(ValueofJet, info1, goals1)
fuel += i - os.time()
print(fuel, i)
Healthup:Play()
if not turnon or fuel == 0 then
Healthup:Play()
break
end
end
coroutine.yield()
end)
drainingFuelC()
end