Tween Service not working in Collection Service

Hello! I was wondering why this tween is not working with the Collection Service. I tried replacing stuff but it didn’t work.

Here is my script:

local tweenService = game:GetService("TweenService")

local function SimpleTween(Object, Length, Style, Direction, Properties)
    local Tween = tweenService:Create(
        Object,
        TweenInfo.new(Length, Enum.EasingStyle[Style].Value, Enum.EasingDirection[Direction].Value),
        Properties
    )

    Tween:Play()
    Tween.Completed:Wait()
    Tween:Destroy()
end


local CS = game:GetService("CollectionService")

local taggedParts = CS:GetTagged("Neon")

for _, texture in pairs(taggedParts) do
    while true do
        SimpleTween(texture, 1, "Linear", "Out", { Color = Color3.fromRGB(97, 144, 255) })
        SimpleTween(texture, 1, "Linear", "Out", { Color = Color3.fromRGB(255, 84, 210) })
    end
end

What exactly do you mean by “its not working” is there any errors?

There’s no errors in the output.

For this

Enum.EasingStyle[Style].Value, Enum.EasingDirection[Direction].Value

I’m pretty sure you don’t need .Value

It still don’t work. Do you this it’s how I place the function of the loops inside of a for loop?

Oh you put the tweens in a while true do loop so it will just keep tweening that singular texture for ever

What do you mean by that? I’m a little confused.

It will just do this

SimpleTween(texture, 1, "Linear", "Out", { Color = Color3.fromRGB(97, 144, 255) })
SimpleTween(texture, 1, "Linear", "Out", { Color = Color3.fromRGB(255, 84, 210) })

forever on one texture and I don’t know what exactly you wanna do

I want the tween to loop all over again.

Oh just use spawn() since that runs the function and doesn’t yield the script

for _, texture in pairs(taggedParts) do
  spawn(function()
    while true do
      SimpleTween(texture, 1, "Linear", "Out", { Color = Color3.fromRGB(97, 144, 255) })
      SimpleTween(texture, 1, "Linear", "Out", { Color = Color3.fromRGB(255, 84, 210) })
    end
  end)
end
1 Like

What I am getting from this is you want all the tagged textures to change color?

1 Like

It works! Thank you so much :))

1 Like