What do I want to achieve?
I’m trying to make a car spawning system for my (experience)
What’s the problem?
When I play test pretty much everything works fine, but pretty much randomly I get an error in the console saying Error indexing nil with IsA() and no new cars can spawn from that player neither can they be deleted.
Here’s the if statement I get the error on:
if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") or player.Character.Humanoid.SeatPart:IsA("Seat") then
player.Character.Humanoid.Sit = false
Keep in mind, this script worked fine before I added the or part.
This is also inside of a TextButton in StarterGui
if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") then
player.Character.Humanoid.Sit = false
elseif player.Character.Humanoid.SeatPart:IsA("Seat") then
end
--// Instead of this
if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") or player.Character.Humanoid.SeatPart:IsA("Seat") then
--// Do this
if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") or player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("Seat") then