Stalker157 Posted August 22, 2022 Share Posted August 22, 2022 Hello, I'm just trying to make a respawn vehicle script for my server but it's not working. function isVehicleOccupied(vehicle) assert(isElement(vehicle) and getElementType(vehicle) == "vehicle", "Bad argument @ isVehicleOccupied [expected vehicle, got " .. tostring(vehicle) .. "]") local _, occupant = next(getVehicleOccupants(vehicle)) return occupant and true, occupant end function respawn(car) if not isVehicleOccupied(Taxi) then respawnVehicle(Taxi) end end function inactive(vehicle) local car = vehicle setTimer(respawn, 5000, 1 , car) end addEventHandler ("onPlayerVehicleExit", root, inactive) I wanna make it if a player exited a vehicle he was driving it will respawn after some time(5 seconds for now, just testing), but I always get error Quote Bad argument @ isVehicleOccupied [expected vehicle, got nil] Can anyone help? Link to comment
markenic Posted August 22, 2022 Share Posted August 22, 2022 In the respawn function you get a variable with "car" name but you use a Taxi named variable. Instead of this function respawn(car) if not isVehicleOccupied(Taxi) then respawnVehicle(Taxi) end end you should try this function respawn(car) if not isVehicleOccupied(car) then respawnVehicle(car) end end Link to comment
Stalker157 Posted August 22, 2022 Author Share Posted August 22, 2022 It works now, thank you. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now