So I have this loop to position a pet behind a player
while true do
wait()
if Pet.Driver.BodyPosition then
Pet.Driver.BodyPosition.Position = --vector 3 postion thing
end
end
But when I request for the Pet to be Destroyed as the player has unequipped it, it appears with that error as stated in the title, but surely the IF statement would prevent this? The code continues to run but I would prefer to not have the error every time the player does this.

5 comments
But wouldn't using :FindFirstChild be taxing on the games performance?
It is the proper way to check if something is there, you can delete the last one if Driver is destroyed with the pet or even just Pet if the pet is destroyed.
The script doesn't throw an error when I use a loading variable and a wait(1), but preferably I'd like to use this instantaneously
Please check my new edit, I'm telling you the proper way to do it whether or not you feel you like it.
i understand :(