Referencing model on client-side outputs 0 children

--|| Client
local ClientTween = game:GetService("ReplicatedStorage").RemoteEvents.ClientTween


ClientTween.OnClientEvent:Connect(function(modelName)
	for _, model in pairs(workspace.Tycoons["Tycoon [1]"]["Purchased Buildings"]:GetChildren()) do
		if model.Name == modelName then
			print(model)
			
			if model then
				print("Exists.")
				
				if model:IsA("Model") then
					print("This is a model")
				else
					print(typeof(model))
				end
				
				print(#model:GetChildren())
				
				for _, parts in pairs(model:GetChildren()) do
					print(parts)
					parts.Transparency = 0.5
					print(parts.Transparency)
				end
				
			end
		end
	end
end)
--|| Server Script
	if Animate == true then
		print("Line 1588 fired.")
		ClientTween:FireAllClients(Pads.Name)
	end

I’m trying to reference a model in the workspace in a folder after passing in the name of the model through FireAllClients. In the OnClientEvent, the model name is printed and I’ve made sure that the model exists in the workspace as well as if the model is a model itself. The amount of children in the model however prints out 0 which I don’t understand. What could be causing this? Thank you for any help!

If you run this script on the server, does it also print 0?

1 Like

Running on the server prints out 2. I wonder why the client cant see the model’s children?

I think it’s replication lag, Roblox is top down model I believe so it replicates model → children

Try using children added event as well to see if it prints anything.

				print(#model:GetChildren())
				
				for _, parts in pairs(model:GetChildren()) do
					print(parts)
					parts.Transparency = 0.5
					print(parts.Transparency)
				end
model.ChildrenAdded:Connect(function(child)
					print(parts)
					parts.Transparency = 0.5
					print(parts.Transparency)
end)
1 Like

So I did

local ClientTween = game:GetService("ReplicatedStorage").RemoteEvents.ClientTween


ClientTween.OnClientEvent:Connect(function(modelName)
	wait(3)
	print(#modelName:GetChildren())
end)

And sure enough it prints the same amount of children that the server has. How could I ensure that the replication for the client matches the amount of children in the server before performing changes to the model?