Is there a function to check if something is in the game in the form of an if statement

so basically how do I make a function that goes like

local food = instance.new("Part")
if [food is in the game] then

end

Check out :IsDescendantOf

local food = Instance.new("Part")-- your food
print(food:IsDescendantOf(game)) -- false
food.Parent = workspace
print(food:IsDescendantOf(game)) -- true
local food = Instance.new("Part") -- Instance.

if food ~= nil then -- If food is different from nil then:
print("Yes")
else -- if not:
print("No")
end

I think its it.
Using if/then Statements (roblox.com)
Conditional Structures (roblox.com)

What do you mean by in the game? Do you mean if it exists?

Without parenting food first, its parent would be nil and thus it would not be a descendant of the DataModel which has the global variable named “game” point/refer to it.