Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would you check for a vehicle's occupant?

Asked by 8 years ago

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

0
That means something is wrong with the object or value. The value or object cannot be found in that location! legobuildermaster 220 — 8y
0
I wonder what's wrong with it, because I was trying to find the Occupant and I know that the Occupant is Humanoid. Cyotokatrov 20 — 8y
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 Ryzox 220 — 8y

Answer this question