I've tried this:

function UseFuel()
	if script.Parent.Parent.Drive.Occupant.Changed then
		for i = 1, script.Parent.Fuel.Value do
			script.Parent.Fuel = script.Parent.Fuel - 1
		end
	end
end

script.Parent.Parent.Drive.Occupant.Changed:connect(UseFuel)

But the output is always the same:

Workspace.Sedan.FuelPeice.FuelScript:60: attempt to index field 'Occupant' (a nil value) 11:42:29.181 - Stack Begin 11:42:29.182 - Script 'Workspace.Sedan.FuelPeice.FuelScript', Line 60 11:42:29.183 - Stack End

3 comments

0

That means something is wrong with the object or value. The value or object cannot be found in that location!

0

I wonder what's wrong with it, because I was trying to find the Occupant and I know that the Occupant is Humanoid.

0

I'm guessing drive is the seat, well Occupant isn't in the seat until they sit down so you can't exactly declare occupant there, you will have to do childadded event on drive and check for occupant