Infinite yield possible on script.EyeSpawner:WaitForChild("cframe")

What do you want to achieve?
Fix the error in the script
What is the issue?
It say Infinite yield possible on ‘Players.playerName.Backpack.OverseerAxe.SwordScript.EyeSpawner:WaitForChild(“cframe”)’ - Studio
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried to find something that could help me on Dev Forum but I couldn’t see anything that can help me

SwordScript
local cframeValue = script:WaitForChild("cframe")

This is the script "EyeSpawner", Parent is SwordScript
--function SpawnEye(humanoid)
	if not humanoid.Torso then return end
	local target = humanoid.Torso.CFrame.p
	local cframe = (sp:FindFirstChild("cframe") or Instance.new("CFrameValue"))
	--local cframe = Instance.new('CFrameValue')
	cframe.Value = CFrame.new(target+Vector3.new(2+(5*math.random()),3,2+(5*math.random())),target)
	cframe.Name ='cframe'
	cframe.Parent = EyeSpawner
	EyeSpawner.Disabled = true
	EyeSpawner.Disabled = false
end

There’s no object named cframe inside the EyeSpawner script, it’s either that or you’re calling an unnecessary WaitForChild() infinitely yielding until there is a cframe object

1 Like

Oh, but how can I fix this?
I’m new to this.

I guess I’ll have to do this myself, btw thx for helping me :smiley:

local cframeValue = script.cframe

For me, that didn’t work, it just make the new part spawn at another position.

Is your value adding under the script?

I think you’re parenting the value to the wrong script. You wrote:
cframe.Parent = EyeSpawner
While WaitForChild is waiting for an addition under itself, SwordScript.
Try changing it to:
cframe.Parent = SwordScript?

In your code you have been referencing cframe as if it was an object, but Im assuming you just wanted to get the cframe and offset it by a random amount?
In that case just try

EyeSpawner.CFrame = target.CFrame:ToWorldSpace(CFrame.new(*offset cframe))

of course I havnt tested it or anything and I have no idea how your game is structured so it might not work or I might have misinterpreted something

Let me try this, I hope this will work

That doesn’t work, the parent is correct

The value will change to where the target is