While true do loop not working

Hello! I am trying to make a humanoid figure appear for 1 second, then disappear for 15. And I want this to loop.

However It never appears and I don’t know what to do
image

Script:

local descendants = script.Parent:GetDescendants()


for _, descendant in pairs(descendants) do
	if descendant:IsA("BasePart") then
		descendant.Transparency = 1

	end
end

script.Parent.MeshPart.Transparency = 1



while true do 
	wait()
	descendants.Transparency = 0
	wait(1)	
	descendants.Transparency = 1
	wait(15)
end


It disappears as intended but it won’t reappear.

All help appreciated!

Your script isn’t reappearing the humanoid figure as intended because the way you’re setting transparency for descendants isn’t working as expected. Try this instead:

local descendants = script.Parent:GetDescendants()

for _, descendant in pairs(descendants) do
    if descendant:IsA("BasePart") then
        descendant.Transparency = 1
    end
end


if script.Parent.MeshPart:IsA("BasePart") then
    script.Parent.MeshPart.Transparency = 1
end

while true do
    for _, descendant in pairs(descendants) do
        if descendant:IsA("BasePart") then
            descendant.Transparency = 0
        end
    end

    wait(1)

    for _, descendant in pairs(descendants) do
        if descendant:IsA("BasePart") then
            descendant.Transparency = 1
        end
    end

    wait(15)
end

This should create the appearance and disappearance loop for your figure/NPC or whatever.

Best regards, Xeth

1 Like

Does it work now if not please tell me, I would definetly help in any way or so?

I said that the humanoid root part was appearing and I didn’t know how to stop it from appearing. I just decided to delete it altogether. But tysm for the help!

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