Cannot find an object in replicated storage even though it clearly is there

So today i’ve tried experimenting a little bit with tables and tried a very simple crafting system.
Everything worked fine exept when i tried making the viewport frame for the object that is going to be crafted. I choose a way to store the Model and camera for the viewport frame using replicated storage where i put these two in a folder and then stored the paths to the in a table.
The problem is that the script cannot find the camera, but can find the Model even though they’re in the same folder and when i hit run the camera is still there.

Maybe it is, becuase i cannot store paths to objects in tables, but it seems like i can considering the fact that when i tried printing the paths in output, it showed me the model.

Also please consider the fact that i don’t know tables very good

Here is the script :

local Tools = {
	Axe = {"Log", "Fiber", ReplicatedStorage.ToolViewports.Axe.Model, ReplicatedStorage.ToolViewports.Axe:FindFirstChild("Camera")}
}

for _, button in pairs(recipes_frame:GetChildren()) do
if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()
			if button.Name == "Axe" then
				requirements_frame.Requirement1.Text = Tools.Axe[1]
				requirements_frame.Requirement2.Text = Tools.Axe[2]
				local ViewportModel = Tools.Axe[3]
				local ViewportCamera = Tools.Axe[4]
				print(ViewportModel)
				print(ViewportCamera)
			end
		end)
	end
end
1 Like

The client may not always have everything replicated when the script runs. You should use :WaitForChild() to get the instance

I already tried that, but it just prints out nil :frowning:

Like @Sluethen said, don’t use FindFirstChild(). FindFirstChild() should be only used if you are unsure whether an object exists. You need to use WaitForChild() so that the string will yield until the necessary object has replicated.

You need to move the WaitForChild up higher then, probably to ReplicatedStorage:WaitForChild(“ToolViewports”)

Replied to wrong person, whoops
Nvm it was the right person

Well using WaitForChild is kinda wierd in this situation.
It either says “nil” or says infinite yield possible.

After 5 seconds the Infinite Yield is thrown, the instance can be registered after that. Make sure that the name is exactly right when entered.

I’m 100% sure that the name is right, because i can just press Tab to enter it.

Unforunately, cameras do not replicate. You have to make a new one.