Infinite yield problem

I know that infinite yield is just a warning but, it it doesn’t even do the local function. How do i fix this?

local replicatedstorage = game:GetService("ReplicatedStorage")
local armormodule = require(game.ServerScriptService:WaitForChild("ArmorHandler"))
	local function addToFrame(armor)
		local template = script.Parent.MainGui.Inventory.Templates.Template
		
		local newTemplate = template:Clone()
		newTemplate.Parent =  script.Parent.MainGui.Inventory.Duplicates
		newTemplate.Visible = true
		
		local newArmor = armormodule.chooseRandom():Clone()
		
		local camera = Instance.new("Camera")
		camera.CFrame = CFrame.new(newArmor.PrimaryPart.Position + (newArmor.PrimaryPart.CFrame.lookVector * 3), newArmor.PrimaryPart.Position)
		camera.Parent = newTemplate.ViewportFrame
		
		newTemplate.ViewportFrame.CurrentCamera = camera
end

replicatedstorage.Events.UpdateInventory.OnClientEvent:Connect(function(player, armor)
	addToFrame(armor)
end)

The client can’t access the contents of ServerScriptService, move the module to ReplicatedStorage

The infinite yield warning is when you do :WaitForChild(“String”) and leave the second parameter (the number timeout) empty.

yes, now it works but can you also help me with

You forgot to set PrimaryPart on the armor.

1 Like

what do i set it to??

That error is trying to say that newArmor.PrimaryPart is nil (meaning it doesn’t exist or have a value)

the armor looks like this

the armor looks like that on top, what do i set it to?

You would have to create a base part for the armor similar to how player characters have HumanoidRootPart and set the Armor’s primary part to it

so i set it to?
Screen Shot 2021-03-13 at 12.40.29 PM

If the armor is going to attach to the player’s character then yea. But if it’s for display, you would have to create a new Part and set it to that

It’s just blank?
Screen Shot 2021-03-13 at 12.43.27 PM

You have to parent the armor to the viewportframe

Yes

newArmor.Parent = newTemplate.ViewportFrame

in the script?

yay, thanks it works now!