Infinite yield possible

I get
image
when trying to wait for a WeldConstraint to load and I’ve tried using math.huge or a number in the script but it stops the rest of the script from working or gives an error or an infinite yield again

The infinite yield sometimes stops the script from working as well.

script:

local weldB = script.Parent:WaitForChild("WeldConstraint")
wait()

weldB:GetPropertyChangedSignal("Enabled"):Connect(function()
	wait(4)
    script.Parent:Destroy()
end)

I’ve also tried FindFirstChild which just gives me another error
image

2 Likes

I think putting math.huge halts the script because that instance just doesn’t exist. You should playtest the game and check in the explorer for that weld while playing.

Try using FindFirstChild

local weldB = script.Parent:FindFirstChild("WeldConstraint")

Info :

1 Like

I’d do that if i was just looking for the weld but its part of the rest of a script that line was just a portion.

local weldB = script.Parent:WaitForChild("WeldConstraint")
wait()

weldB:GetPropertyChangedSignal("Enabled"):Connect(function()
	wait(4)
    script.Parent:Destroy()
end)

When I try to do that I just get
image

Maybe disable the last four lines with a comment so you can check if the weld exists.

1 Like

Umm…

script.Parent:FindFirstChild("WeldConstraint"):GetPropertyChangedSignal("Enabled"):Connect(function()

wait(4)

script.Parent:Destroy()

end)
1 Like

Yes it does it loads the weld.

Can you post a screenshot of where the weld is in the explorer?

1 Like

image

It just gives this again
image

Can you please rename other WeldConstrait? because you are only looking for one and you name both Weld.

1 Like

You should rename the weld you’re trying to reference, otherwise the script doesn’t know which one you’re talking about.

Ok yes that works thanks I can see what the issue is there now. Thanks

Yeah I see where I went wrong now thank you

1 Like