Check if a model exists or is nil

So i got a NPC script which makes the NPC do some different actions in my game for an example walk to a chair and sit in it but i got a build system which includes removing and moving models. So if the NPC would walk to a chair and the player removes the model, it would not exist anymore and that would make an error in the NPC script as it can not find the model anymore.

I have tried to make a check to see if the model is == nil but i still get some errors and im just asking if anyone knows a good solution to have some control checks in your script like “if model do not exist” then “do this”.

I dont need full scripts or anything just some help with the thinking.

Perhaps use:

if not game.Workspace:FindFirstChild("Chair") then return end --change chair to whatever your model's name is
2 Likes

I belive it was that simple haha thx man!

1 Like