-
What do you want to achieve? Keep it simple and clear!
I want to change the color of multiple parts by using gui buttons. Each button has a script that has different tween info that will change the color of the parts. I want to be able to click on the button so that it stops the current tweens in one script and plays the tweens in the script from the new gui button. -
What is the issue? Include screenshots / videos if possible!
The issue is that when the tweens are playing from one script and click the button with the script that has new tweens, the old tweens do not stop. Instead all the tweens play at the same time and the parts begin to change colors between the tweens of both scripts. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have considered checking when one button is pressed so that i can disable the script from the other button to stop its tweens but i dont think that works.
Here is the script from the “Blue” button.
local Button = script.Parent
local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, false, 0)
Button.MouseButton1Click:Connect(function()
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 1")) do
TweenService:Create(v, Info, {Color = Color3.new(0.333333, 0.333333, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(1)
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 2")) do
TweenService:Create(v, Info, {Color = Color3.new(0.333333, 0.333333, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(1)
end)
Button.MouseButton1Click:Connect(function()
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop LED Lights Center Ring")) do
TweenService:Create(v, Info, {Color = Color3.new(0.333333, 0.666667, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(.5)
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop LED Lights Middle Ring")) do
TweenService:Create(v, Info, {Color = Color3.new(0.333333, 0.333333, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(.30)
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop LED Lights Outer Ring")) do
TweenService:Create(v, Info, {Color = Color3.new(0.333333, 0, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(.55)
print("Lights Color Changed")
end)
and here is the script for the “Fuscia” button which is the same thing just with different tween infos.
local Button = script.Parent
local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true, 0)
Button.MouseButton1Click:Connect(function()
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 1")) do
TweenService:Create(v, Info, {Color = Color3.new(1, 0, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(1)
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 2")) do
TweenService:Create(v, Info, {Color = Color3.new(1, 0, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(1)
end)
Button.MouseButton1Click:Connect(function()
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop LED Lights Center Ring")) do
TweenService:Create(v, Info, {Color = Color3.new(1, 0.333333, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(.5)
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop LED Lights Middle Ring")) do
TweenService:Create(v, Info, {Color = Color3.new(1, 0, 1)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(.30)
for i,v in pairs(CollectionService:GetTagged("Mainstage Backdrop LED Lights Outer Ring")) do
TweenService:Create(v, Info, {Color = Color3.new(1, 0, 0.498039)}):Play()
v.Material = Enum.Material.Neon
end
task.wait(.55)
print("Lights Color Changed")
end)
If needed here is the explorer tab that shows where each button with their script is (ScreenGui is not mine, I am using/customizing a free one I found on YouTube just fyi)!
And here is a video showing how the colors begin to change simultaneously.