So I’m using this script to tween a parts color, however, it keeps flashing the colors instead of tweening them nicely. Here’s the script:
local CurrentColor = Color3.new(1, 0, 0)
local TweenService = game:GetService("TweenService")
local TweenTime = 0.5
local TweenInfoX = TweenInfo.new(TweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local Counter = 1
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
task.spawn(function()
while task.wait() do
task.wait()
if Counter == 1 then
CurrentColor = Color3.new(1, 0, 0)
elseif Counter == 2 then
CurrentColor = Color3.new(0.835294, 0.45098, 0.239216)
elseif Counter == 3 then
CurrentColor = Color3.new(1, 1, 0)
elseif Counter == 4 then
CurrentColor = Color3.new(0, 255, 0)
elseif Counter == 5 then
CurrentColor = Color3.new(18, 238, 212)
elseif Counter == 6 then
CurrentColor = Color3.new(255, 0, 191)
end
task.wait()
local A = TweenService:Create(script.Parent, TweenInfoX, {Color = CurrentColor})
local B = TweenService:Create(script.Parent:FindFirstChild("Beak"), TweenInfoX, {Color = CurrentColor})
local C = TweenService:Create(script.Parent:FindFirstChild("Upper Torso"), TweenInfoX, {Color = CurrentColor})
A:Play()
B:Play()
C:Play()
task.wait(1)
if Counter >= 6 then
Counter = 0
end
if script.Parent.Color ~= CurrentColor then
script.Parent.Color = CurrentColor
end
if script.Parent:FindFirstChild("Beak").Color ~= CurrentColor then
script.Parent:FindFirstChild("Beak").Color = CurrentColor
end
if script.Parent:FindFirstChild("Upper Torso").Color ~= CurrentColor then
script.Parent:FindFirstChild("Upper Torso").Color = CurrentColor
end
Counter += 1
end
end)
end)
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
task.spawn(function()
while task.wait() do
task.wait()
if Counter == 1 then
CurrentColor = Color3.new(1, 0, 0)
elseif Counter == 2 then
CurrentColor = Color3.new(0.835294, 0.45098, 0.239216)
elseif Counter == 3 then
CurrentColor = Color3.new(1, 1, 0)
elseif Counter == 4 then
CurrentColor = Color3.new(0, 255, 0)
elseif Counter == 5 then
CurrentColor = Color3.new(18, 238, 212)
elseif Counter == 6 then
CurrentColor = Color3.new(255, 0, 191)
end
task.wait()
local A = TweenService:Create(script.Parent, TweenInfoX, {Color = CurrentColor})
local B = TweenService:Create(script.Parent:FindFirstChild("Beak"), TweenInfoX, {Color = CurrentColor})
local C = TweenService:Create(script.Parent:FindFirstChild("Upper Torso"), TweenInfoX, {Color = CurrentColor})
A:Play()
B:Play()
C:Play()
A.Completed:Wait() -- yields code until the Tween is completed
if Counter >= 6 then
Counter = 0
end
if script.Parent.Color ~= CurrentColor then
script.Parent.Color = CurrentColor
end
if script.Parent:FindFirstChild("Beak").Color ~= CurrentColor then
script.Parent:FindFirstChild("Beak").Color = CurrentColor
end
if script.Parent:FindFirstChild("Upper Torso").Color ~= CurrentColor then
script.Parent:FindFirstChild("Upper Torso").Color = CurrentColor
end
Counter += 1
end
end)
end)
local CurrentColor = Color3.new(1, 0, 0)
local TweenService = game:GetService("TweenService")
local TweenTime = 0.5
local TweenInfoX = TweenInfo.new(TweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local Counter = 1
function CheckCounter()
if Counter == 1 then
return Color3.new(1, 0, 0)
elseif Counter == 2 then
return Color3.new(0.835294, 0.45098, 0.239216)
elseif Counter == 3 then
return Color3.new(1, 1, 0)
elseif Counter == 5 then
return Color3.new(18, 238, 212)
elseif Counter == 6 then
return CurrentColor = Color3.new(255, 0, 191)
end
end)
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
task.spawn(function()
CurrentColor = CheckCounter()
local A = TweenService:Create(script.Parent, TweenInfoX, {Color = CurrentColor})
local B = TweenService:Create(script.Parent:FindFirstChild("Beak"), TweenInfoX, {Color = CurrentColor})
local C = TweenService:Create(script.Parent:FindFirstChild("Upper Torso"), TweenInfoX, {Color = CurrentColor})
A.Completed:Wait()
if Counter >= 6 then
Counter = 0
end
if script.Parent.Color ~= CurrentColor then
script.Parent.Color = CurrentColor
end
if script.Parent:FindFirstChild("Beak").Color ~= CurrentColor then
script.Parent:FindFirstChild("Beak").Color = CurrentColor
end
if script.Parent:FindFirstChild("Upper Torso").Color ~= CurrentColor then
script.Parent:FindFirstChild("Upper Torso").Color = CurrentColor
end
Counter += 1
end
end)
end)
local CurrentColor = Color3.new(1, 0, 0)
local TweenService = game:GetService("TweenService")
local TweenTime = 0.5
local TweenInfoX = TweenInfo.new(TweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local Counter = 1
local Colors = {Color3.new(1, 0, 0), Color3.new(0.835294, 0.45098, 0.239216), Color3.new(1, 1, 0), Color3.new(0, 255, 0), Color3.new(0.239216, 0.466667, 1), Color3.new(255, 0, 191)}
local D = 0
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
if D == 0 then
D += 1
task.wait()
task.spawn(function()
while task.wait() do
CurrentColor = Colors[Counter]
local A = TweenService:Create(script.Parent, TweenInfoX, {Color = CurrentColor})
local B = TweenService:Create(script.Parent:FindFirstChild("Beak"), TweenInfoX, {Color = CurrentColor})
local C = TweenService:Create(script.Parent:FindFirstChild("Upper Torso"), TweenInfoX, {Color = CurrentColor})
A:Play()
B:Play()
C:Play()
A.Completed:Wait()
if Counter >= 6 then
Counter = 0
end
if script.Parent.Color ~= CurrentColor then
script.Parent.Color = CurrentColor
end
if script.Parent:FindFirstChild("Beak").Color ~= CurrentColor then
script.Parent:FindFirstChild("Beak").Color = CurrentColor
end
if script.Parent:FindFirstChild("Upper Torso").Color ~= CurrentColor then
script.Parent:FindFirstChild("Upper Torso").Color = CurrentColor
end
Counter += 1
end
end)
end
end)
This is what I have at the moment, I thought maybe the parent was changing multiple times and maybe the loops runs more than once (So I added the ‘D’ constant), but that doesn’t seem to be it.
But I do believe that the loop is running more than once. I’m not sure why.