Check if an object is restricted

Is there any way to check if an object is restricted in order to prevent this?
image
I tried searching for posts and they either don’t exist or I was putting in the wrong keywords.

If you’re creating a loop or a system that iterates through the game, use a pcall. Accessing any part of a locked object will cause an error.

1 Like

Is there any way to actually checked if it is a locked object, or is a pcall the only way?

There’s a property called RobloxLocked but it’s deprecated and doesn’t do anything anymore. Your best bet would be to use a pcall.