Anyway to do multiple things at once in TweenService?

So i did a for loop like this to get multiple things to do a tween at once, but all it does is works for one
thing. This has been hurting my brain

        for _,v in pairs(ScreenGui.Picker:GetChildren()) do
            if v:IsA("TextLabel") or v:IsA("TextButton") then
                ScreenFade2 = TweenService:Create(ScreenGui.Picker, Tweeninfo, {BackgroundTransparency = 0})
                ScreenFade3 = TweenService:Create(v, Tweeninfo, {BackgroundTransparency = 0})
                ScreenFade4 = TweenService:Create(v, Tweeninfo, {TextTransparency = 0})
            end
        end

Do you know any way i could achieve this differently or the same way?

You’re not playing them though??? (Ignore)

Make them local, each time you go through an instance in the loop, it overrides the last set variable. Make them local, and play them in the for loop as you go.

Im not showing that part sorry. Ill give more

ProxP.Triggered:Connect(function(Player)
    if Player then
        print(Player.Parent)
        ScreenGui = Player.PlayerGui:WaitForChild("ElevatorGui")
        for _,v in pairs(ScreenGui.Picker:GetChildren()) do
            if v:IsA("TextLabel") or v:IsA("TextButton") then
                ScreenFade2 = TweenService:Create(ScreenGui.Picker, Tweeninfo, {BackgroundTransparency = 0})
                ScreenFade3 = TweenService:Create(v, Tweeninfo, {BackgroundTransparency = 0})
                ScreenFade4 = TweenService:Create(v, Tweeninfo, {TextTransparency = 0})
            end
        end
        ScreenGui.Enabled = true
        local ScreenFade1 = TweenService:Create(ScreenGui.Fade, Tweeninfo, {BackgroundTransparency = 0})
        ScreenFade1:Play()
        ScreenFade1.Completed:Wait()
        ScreenGui.Picker.Visible = true
        ScreenFade2:Play()
        ScreenFade3:Play()
        ScreenFade4:Play()
        ScreenGui.Fade.Visible = false
    end
end)

Did you try checking if the text buttons and labels aren’t nil? TweenService doesn’t error if the instance you pass is nil

I’ve just finished a similar thing for a game I’m working on. What I did was store all the tweens that needed to be played in a table, then used a simple for loop to play them when they need to be played.
For example:
for index, value in ipairs(toTween) do
value:Play()
end

1 Like

You can do smoething like

ScreenFade2 = TweenService:Create(v, Tweeninfo, {BackgroundTransparency = 0, TextTransparency = 0})

That then tweens both the background and text transparency together

1 Like

You’re looping and overriding the ScreenFade2, ScreenFade3, and ScreenFade4 on every iteration. Try storing it in a table and playing them all at once.

ProxP.Triggered:Connect(function(Player)
	if Player then
		print(Player.Parent)
		ScreenGui = Player.PlayerGui:WaitForChild("ElevatorGui")
		local fades = {}
		for _,v in pairs(ScreenGui.Picker:GetChildren()) do
			if v:IsA("TextLabel") or v:IsA("TextButton") then
				local ScreenFade2 = TweenService:Create(ScreenGui.Picker, Tweeninfo, {BackgroundTransparency = 0})
				local ScreenFade3 = TweenService:Create(v, Tweeninfo, {BackgroundTransparency = 0})
				local ScreenFade4 = TweenService:Create(v, Tweeninfo, {TextTransparency = 0})
				table.insert(fades, ScreenFade2)
				table.insert(fades, ScreenFade3)
				table.insert(fades, ScreenFade4)
			end
		end
		ScreenGui.Enabled = true
		local ScreenFade1 = TweenService:Create(ScreenGui.Fade, Tweeninfo, {BackgroundTransparency = 0})
		ScreenFade1:Play()
		ScreenFade1.Completed:Wait()
		ScreenGui.Picker.Visible = true
		for _, fadeTween in pairs(fades) do
			fadeTween:Play()
		end
		ScreenGui.Fade.Visible = false
	end
end)

also your variables don’t seem to use proper scopes