Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My fuel consumption script doesnt do anything,can i have some help?

i'm trying to make fuel consumption based on the throttle of the ship but it just doesnt work can someone help?

FuelQT = script.Parent.FuelAmt
Throttle = script.Parent.Parent.Values.Thrust
EngineOn = script.Parent.Parent.Values.EngineOn
FuelRM = script.Parent.FuelRM
Fuel = script.Parent.Fuel
while EngineOn == true do
	Fuel = Fuel-Throttle/5
	if Fuel <= 0 then
			EngineOn = false
		end
end

1 comment

0

if engine starts off, the loop won't run

1 answer

Hello.

Upon reading your script, I noticed a few things.

To start off, I assume EngineOn is a BooleanValue instance. That said, the instance itself will never be true. However, EngineOn.Value could be true.

When attempting to call upon or change a Value instance's value, you must change it using the .Value property.

This will also apply to your Fuel, Throttle, FuelQT, and FuelRM variables.

Secondly, if EngineOn.Value is false from the start, then your loop will never run. As well, once EngineOn.Value is set to false from true, the loop will end and will not restart. You could perhaps used the .Changed event to counter this.

For example:

EngineOn.Changed:Connect(someFunction)

If you need further assistance, join the Discord!

This discussion is preserved as it was. New answers, comments, and votes are closed.