Question about assigning object to variable

I want to assign an object to a variable, however that object isn’t guaranteed to be present at all times How would I do this without everything breaking?

By ‘not being present,’ what do you mean?

You can do this:

local Object = some_parent:FindFirstChild("OBJECT_NAME")

-- Must check if the object exists. Note, this will not recheck if the object exists,
-- this only confirms if the object existed at creation of the variable above.
if Object then

1 Like

So could I replace if Object then with if (where the object should be) then?

Yes, you can do this, though you won’t be able to have a variable for this. So if you wish to assign it to a variable, my solution above will work, either way both options are appropriate.