How do I set a variable when the object is there?

I am trying to assign a variable like this:

local InvisibleParts = workspace.Model

but at the start of the server, this model doesn’t exist. So how would I assign the variable after it exists? I was thinking of something like this:

local InvisibleParts
repeat InvisibleParts = workspace.Model until (workspace.Model)

Try using Instance:WaitForChild(). It yields until a child with the given name appears, then continues. For example:

local InvisibleParts = workspace:WaitForChild("Model")

I’d also recommend changing the invisible parts model name, since just “Model” is generic and could get mixed up with other things.

I am adding the model after around 4 minutes, so WaitForChild will raise a warning, and I don’t want that.

This was an example.

I’d recommend checking if it exists when the thing that needs it runs. For example:

local InvisibleParts -- Set a blank variable like you did in your example

-- Seperation

InvisibleParts = workspace:FindFirstChild("Model")
if InvisibleParts then
-- Do stuff
end

I actually managed to fix this by doing:

local InvisibleParts = nil
local InvisiblePartsConnection
InvisiblePartsConnection = workspace.ChildAdded:Connect(function(Child)
	if Child.Name == "Model" and Child:IsA("Model") then -- sanity checks
		InvisibleParts = Child
		InvisiblePartsConnection:Disconnect()
	end
end)

you can add a timer to WaitForChild so that it waits until time is up before giving a warning, you can use math.huge to make it wait forever.

workspace:WaitForChild("Model", math.huge)