Hook problem

After a random amount of time my Hook from VU-Mod stops working suddently.

This is the line of code that gives the error:

local Passangers = vehicle.VehicleTable.Passengers or vehicle:GetParent().VehicleTable.Passengers or nil

And this is the error, that comes up randomly:

[gamemodes\cider\gamemode\core\plugins\vehicles\sv_init.lua:60] attempt to index field ‘VehicleTable’ (a nil value)
Removing Hook ‘vmEnterVehicle’

Anyone got a idea what could be wrong?

VehicleTable is nil. You are trying to read from a table that is not defined (yet).

Ugly but it solves the indexing problem:

local Passangers = ( vehicle.VehicleTable or ).Passengers or ( vehicle:GetParent() or {} ).VehicleTable.Passengers

I don’t even suggest stuff like that. You should always try to find out why something is wrong, instead of hiding it.

And you should always initialize your variables before use, so this doesn’t happen.

I think I fixed the problem:

The first thing was that I did SeatType = “jeep_seat”, instead of SeatType = “Seat_Jeep”,

The second thing was that the PHX seats are in VU-Mod in default, crashed it. So I just deleted them.