Vehicle Spawn System Error

Hi, I’m going to give the Devforum a shot here.

So, I am trying to make a vehicle spawn system that checks if a vehicle is spawned, if it is spawned, it is colored red, if it isn’t, it is colored grey.

The problem is that when I despawn the vehicle, it stays red, and it errors saying the vehicle is not a valid member of Workspace

Script:
error

Any help is appreciated!

Does your script delete the vehicle cause if so that will be the error cause the first line of code says
game.workspace it can be the problem if not tell me.

No it doesn’t, the script is supposed to check if the vehicle is deleted every time an event is fired, and I know the event is working because it errors when it tries to check if the vehicle is deleted.

if you go play and click on the error what line of code does it say where the error is so i can make it easyer for me?

It errors on the if statement on the picture above, and the error is “B157 is not a valid member of workspace”.

Try this instead:

if game.Workspace:FindFirstChild("B"..script.Parent.Name) == nil then

I did, it works, Thank you for the help!

Alright cool put me as solution :slight_smile: