Child transparency script help

I’m making a script where a model’s children’s transparencies slowly dissolve and then appear again and that goes in a loop. It doesn’t work though.

local text = script.Parent
local children = text:GetChildren()

while true do
	for i, child in ipairs(children) do
		for i = 1,100 do
		child.Transparency -= 0.01
			wait(0.005)
		end
	for i, child in ipairs(children) do	
		for i = 1,100 do
			child.Transparency += 0.01
		wait(0.005)
			end
		end
	end 
end


Help appreciated, thank you.

1 Like

What does not work, is it not doing anything at all or is it doing skmetbing but not what you want?

1 Like

Your code is completely wrong and so hard to understand and it is completely okay since you are new,
Here’s better code using tweening
you can learn tweening in the documentation or on youtube it will help you

local text = script.Parent
local children = text:GetChildren()
local TS = game:GetService("TweenService")
for _,Part in pairs(children) do
	TS:Create(Part,TweenInfo.new(0.5,Enums.EasingStyle.Linear,Enums.EasingDirextion.In,-1,true),{Transparency = 0}):Play()
end

I wrote that code bare so maybe it will error but it does the job
:warning: also to make the code work the model parts should have transparency of 1 make sure to set the parts transparency to 1 :warning:

2 Likes

it’s not doing anything at all

I agree, but it was weird to me when it didn’t work because I have made a script using this but just for a part, but when it’s a model it had to capture all the children’s trasparencies and that’s where it didn’t work

thanks :eyes:

As for the code, nothing happened when I ran it and I got some red underlines

What part? Send the line please.

Enums should become Enum.

Replace this line
for _,Part in pairs(children) do

To this
for _,Part in children do

It still doesn’t work but the underlines are gone at least

Is it a script or a local script?

Open your ouput when testing to find errors.

Try this

local text = script.Parent
local children = text:GetChildren()

while true do
    for i, child in ipairs(children) do
        for j = 1, 100 do
            child.Transparency = math.max(0, child.Transparency - 0.01)
            wait(0.005)
        end

        for j = 1, 100 do
            child.Transparency = math.min(1, child.Transparency + 0.01)
            wait(0.005)
        end
    end
end

script

(filling text limitttt)

I tried it it’s not working

It doesn’t matter if the children aren’t parts, as long as they have the transparency property right?

What are you trying to make transparent exactly

Is the instance transparency you’re setting a text label? If so, trying changing Transparency to TextTransparency

A model’s children, mesh parts. It’s a transition between 0 to 1 transparency and vice versa

local text = script.Parent
wait(1)
local children = text:GetChildren()

while true do
	for i = 1,10 do
	  wait(0.005)
	  for i, child in ipairs(children) do
		child.Transparency += 0.1
	  end
    end
	for i = 1,10 do
	  wait(0.005)
	  for i, child in ipairs(children) do
		child.Transparency -= 0.1
	  end
    end
end

I already wrote that, as you can see on my topic. And no it doesn’t work…

try this from @tahabashar1 but changed a little

local text = script.Parent
local children = text:GetChildren()
local TS = game:GetService("TweenService")
for _,Part in pairs(children) do
	if not Part:IsA("BasePart") then continue end
	TS:Create(Part,TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1,true),{Transparency = 1}):Play()
end