of     1   

BrickBrother1
#226774649Tuesday, October 24, 2017 3:00 PM GMT

local car = script.Parent.Parent local gas = car.Gas.Value local driving = car.driving.Value local candrive = car.candrive.Value car.VehicleSeat.Touched:connect(function(hit) print('detected object') if hit.Parent:FindFirstChild('Humanoid') then print('detected humanoid') wait(0.3) if hit.Parent.Humanoid.Sit == true then print('humanoid is sitting') print('car loaded') if gas > 0 then driving = true end else if hit.Parent.Humanoid.Sit == false then driving = false end while true do wait() if gas < 0 then print('car has gas') car.VehicleSeat.MaxSpeed = 0 else print('car is out of gas') car.VehicleSeat.MaxSpeed = 25 end end end end end) the part in "while true do" doesn't run... whats the reason behind this?
WillieTehWierdo200
#226774835Tuesday, October 24, 2017 3:09 PM GMT

It might have something to do with your "else if". In Lua, the keyword for that is "elseif", all one word. When formatted properly, you can see how your script is being read by the Lua interpreter: local car = script.Parent.Parent local gas = car.Gas.Value local driving = car.driving.Value local candrive = car.candrive.Value car.VehicleSeat.Touched:connect(function(hit) print('detected object') if hit.Parent:FindFirstChild('Humanoid') then print('detected humanoid') wait(0.3) if hit.Parent.Humanoid.Sit == true then print('humanoid is sitting') print('car loaded') if gas > 0 then driving = true end else if hit.Parent.Humanoid.Sit == false then driving = false end while true do wait() if gas < 0 then print('car has gas') car.VehicleSeat.MaxSpeed = 0 else print('car is out of gas') car.VehicleSeat.MaxSpeed = 25 end end end end end)
BrickBrother1
#226774995Tuesday, October 24, 2017 3:17 PM GMT

It doesn't work :( I'll just try it on another script..
BrickBrother1
#226775084Tuesday, October 24, 2017 3:21 PM GMT

local car = script.Parent.Parent local gas = car.Gas.Value local driving = car.driving.Value local candrive = car.candrive.Value while true do wait() if gas <= 0 then print('car is out of gas') car.VehicleSeat.MaxSpeed = 0 else print('car has gas') car.VehicleSeat.MaxSpeed = 25 end end Now this wont react if the value of gas is 0.... It is stuck on car has gas..
IsraelGamer101
#226775795Tuesday, October 24, 2017 3:55 PM GMT

the wait() in the while true need to be before you close the whille true not in the first line
IsraelGamer101
#226775865Tuesday, October 24, 2017 3:59 PM GMT

while true do wait() if gas >0 then print('car has gas') car.VehicleSeat.MaxSpeed = 25 else print('car is out of gas') car.VehicleSeat.MaxSpeed = 0 end wait() end
SurKipper
#226775869Tuesday, October 24, 2017 4:00 PM GMT

Change that 'else if hit.Parent.Humaonid.Sit == false then' to 'elseif hit.Parent.Humanoid.Sit == false then' and then delete an 'end' from that stack of ends above 'end)'
IsraelGamer101
#226775890Tuesday, October 24, 2017 4:01 PM GMT

while true do if gas >0 then print('car has gas') car.VehicleSeat.MaxSpeed = 25 else print('car is out of gas') car.VehicleSeat.MaxSpeed = 0 end wait() end
SurKipper
#226775919Tuesday, October 24, 2017 4:02 PM GMT

don't do what I suggested. do you want the while loop to run if the player is sitting?
TaaRt
#226775991Tuesday, October 24, 2017 4:06 PM GMT

gas = 100 speed = 25 while wait() and speed == 25 do if gas > 0 then print('car has ',gas,' gas') gas = gas - 1 else print'car is out of gas' speed = 0 end end
BrickBrother1
#226776032Tuesday, October 24, 2017 4:08 PM GMT

I already fixed it, thanks guys.

    of     1