Transparency tweening does not go when it is specified

hello, I have a script in which when a key is pressed, a different amount of transparency is supposed to appear. but, in the first amount of transparency that is supposed to happen, it doesnt. and when I change the model inside my for loop, it works perfectly fine. help?

my code:

elseif state == 1 then
				local t = TweenInfo.new(fade_time, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0)

				local gtwe1 = TweenService:Create(tb[1], TweenInfo.new(0.05, Enum.EasingStyle.Quint), {ImageTransparency = 1})
				local gtwe2 = TweenService:Create(tb[2], TweenInfo.new(0.05, Enum.EasingStyle.Quint), {ImageTransparency = 0})
				gtwe1:Play()
				gtwe2:Play()		

				for idx, child in pairs(popupsM.Parts.Headlights:GetDescendants()) do
					if child:IsA("SpotLight") then
						local tw = TweenService:Create(child, t, {Brightness = 3.5, Range = 48})
						tw:Play()
					elseif child.Name == "LN" then
						local tw = TweenService:Create(child, t, {Transparency = 0.2})
						tw:Play()	
					end
				end			

desired effect:
https://gyazo.com/a18da559d4b80ef9897d6b833751b3f0

current effect:
https://gyazo.com/73e792fcb5c5018c1681f9422441e288

1 Like

From the wiki:
Tween :Play() won’t yield until the tween is finished

Try putting it in a coroutine or spawn function

Example using spawn:

for idx, child in pairs(popupsM.Parts.Headlights:GetDescendants()) do
    spawn(function()
        if child:IsA("SpotLight") then
            local tw = TweenService:Create(child, t, {Brightness = 3.5, Range = 48})
            tw:Play()
	    elseif child.Name == "LN" then
	        local tw = TweenService:Create(child, t, {Transparency = 0.2})
	        tw:Play()	
	    end
    end)
end

thing is, i use this same function without a spawn function in a different code block, just the model table on the for loop us different. as soon as i had changed it in one of them, only that stopped working.

Where it says tb[1] and tb[2] what did you set those values as?

this block of code is inside a remote event function, the table is sent through the remote. all it does is list imagelabel instances for transparency tweenings.