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) |