TextLabel not Tweening down

Hi Roblox!,
Im in the works of my new game called ____________. I am currently making a You win text label that tweens down when all the parts in a folder are transparent, Can you help me fix it. (PS: There are no errors in the output)

Code:


local TransparentParts = game.Workspace.Devs:GetChildren()
if TransparentParts.Transparency == 1 then
script.Parent:TweenPosition(UDim2.new(0.5,0,0.5,0))
end


Can you help?

Thanks for reading, have a great rest of your day!

1 Like

Also the error is that its not tweening down.

Hello, try this

local TransparentParts = game.Workspace.Devs
local TweenService = game:GetService(“TweenService”)

for i,v in next,(TransparentParts:GetChildren()) do

if v.Transparency == 1 then

  local Win = TweenService:Create(script.Parent,TweenInfo.new(1.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In),{Position = UDim2.new(0.5,0,0.5,0)})
  
  Win:Play()

end

end

thank you, ill try it out now!

1 Like

No this didn’t work i even changed :GetChildren() To :GetDecendants().

1 Like

image

If your parts are all inside the folder, use GetChildren, if they are inside something use GetDescendants

1 Like

There inside a folder, i changed it back. still doesn’t work

It is because you tried to check the transparency of an array of parts (GetChildren()). You should rename one of the main parts to something different than the others and do if workspace.Devs.partName.Transparency == 1 then…

1 Like

in the folder theres multiple parts, what should i do?

Rename any one of the parts in the folder and change the if statement to what I posted above and change partName to the name of the part you changed.

1 Like

GetChildren returns a table without any “Transparency” value, try looping through the children instead.

local TransparentParts = game.Workspace.Devs

for _, part in pairs(TransparentParts:GetChildren()) do
    if part:IsA("BasePart") and part.Transparency == 1 then
        script.Parent:TweenPosition(UDim2.new(0.5,0,0.5,0))
        break
    end
end
1 Like

Players.ScxiptedShark.PlayerGui.Main.YouWin.Label.LocalScript:3: attempt to call a nil value - Client - LocalScript:3

My bad, I forgot to remove :GetChildren() on the first line.

1 Like

im gonna try it now, hope it works!

Nope. it didn’t work :frowning:

As of now, this is only running once so it cannot detect when it is changed. You could use a part.Changed event to detect when the part has been changed or you can just put it in a while loop.

Event example:

for i, v in pairs(game.Workspace.Devs:GetChildren()) do
	if v.Transparency == 1 then
		script.Parent:TweenPosition(UDim2.new(0.5,0,0.5,0))
	end
end

While loop example:

local TransparentParts = game.Workspace.Devs:GetChildren()

while wait() do
    	for i, v in pairs(TransparentParts) do
    		if v.Transparency == 1 then
    			script.Parent:TweenPosition(UDim2.new(0.5,0,0.5,0))
    		end
    	end
    end

ill try the while loop example now.

It works but its tweening down when i click 1, not when i click all of them.

Sorry, I misunderstood, this should work:

local TransparentParts = game.Workspace.Devs:GetChildren()

while wait() do
	local count = 0
	for i, v in pairs(TransparentParts) do
		if v.Transparency == 1 then
			count = count + 1
		end
		if count == #TransparentParts then
			script.Parent:TweenPosition(UDim2.new(0.5,0,0.5,0))
		end
	end
end