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
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
also to make the code work the model parts should have transparency of 1 make sure to set the parts transparency to 1
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
As for the code, nothing happened when I ran it and I got some red underlines
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
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
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