Infinite yield possible on 'Tool:WaitForChild("Handle")'

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Have a tree spawn coconuts after a while they fall then despawn after a bit.

  2. What is the issue? Infinite yield possible on ‘BigCoconut:WaitForChild(“Handle”)’
    Screenshot 2023-08-20 040618

  3. What solutions have you tried so far? Devloper hub, other devs topics, chat gpt, my own will. I havent looked at my old code that was jankie but works. I also tried to force studio to wait for the child with task.wait(CloneBigOne.Handle) and CloneMediumOne:WaitForChild(“Handle”)

local Cs = script.Parent.Parent:FindFirstChild("CoconutSpawns")

local function MuliClone()

	local CloneBigOne = Cs.BigCoconut:Clone()
		CloneBigOne.Handle.Anchored = true
		CloneBigOne.Handle.CanCollide = true
		CloneBigOne.Handle.CanTouch = true
		CloneBigOne.Handle.Transparency = 0
		CloneBigOne.Handle.Parent = workspace["Palm Tree"].Clones

	local CloneMediumOne = Cs.MediumCoconut:Clone()
		CloneMediumOne.Handle.Anchored = true
		CloneMediumOne.Handle.CanCollide = true
		CloneMediumOne.Handle.CanTouch = true
		CloneMediumOne.Handle.Transparency = 0
		CloneMediumOne.Handle.Parent = workspace["Palm Tree"].Clones

	local CloneSmallOne = Cs.SmallCoconut:Clone()
		CloneSmallOne.Handle.Anchored = true
		CloneSmallOne.Handle.CanCollide = true
		CloneSmallOne.Handle.CanTouch = true
		CloneSmallOne.Handle.Transparency = 0
	CloneSmallOne.Handle.Parent = workspace["Palm Tree"].Clones
	
	wait(10)
	CloneBigOne:WaitForChild("Handle")
	task.wait(CloneBigOne.Handle)
	CloneBigOne.Handle.Anchored = false
	CloneMediumOne:WaitForChild("Handle")
	task.wait(CloneMediumOne.Handle)
	CloneMediumOne.Handle.Anchored = false
	CloneSmallOne:WaitForChild("Handle")
	task.wait(CloneSmallOne.Handle)
	CloneSmallOne.Handle.Anchored = false
	
end

while true do
	wait(5)
	local result = math.random(1, 2)
	if result == 1 then
		MuliClone()
	end
	
end
1 Like

If its a local script its because its the client waiting to render that part in, other than that I don’t know.

2 Likes

Thank you so much for helping. It was a Sever script, but I understand the problem now!


You cant wait for a child if that child is the parent.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.