You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
So I have 3 gui buttons, each one that runs a tween on a group of objects with a shared tag. The tween creates a strobe effect by tweening the transparency higher and lower. I want to now make 3 new buttons that will increase the tween speed.
What is the issue? Include screenshots / videos if possible!
The issue is I do not know how to go about this. Each button applies the tween to different groups of parts.
Button 1 = group 1
Button 2 = group 2
Button 3 = group 3
And each button uses the same tween.info. The only thing I need to figure out is how to change the speed regardless of what group is being tweened.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The only thing I can think of that may help find a solution is make “tween speed” buttons for each group… so 3 speed buttons for group 1, 3 for group 2, and 3 for group 3 but I am sure there ia a more effective way of accomplishing this?
local TS = game:GetService("TweenService")
for index, button in pairs(buttonlist:GetChildren()) do
local group= button:GetAttribute("Group").Value
If group == 1 then
TS:Create(1, TweenInfo(3, {"Properties"}):Play()
elseif group == 2 then
TS:Create(1, TweenInfo(1, {"Properties"}):Play()
elseif group == 3 then
TS:Create(1, TweenInfo(2, {"Properties"}):Play()
end
end
if it helps this is the script that im trying to work with.
local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local Module = require(script.LightsManager)
local Button = Module.Buttons
local Bulbs = Module.Bulbs
local TweenInfo = Module.Tween
----------------------------------------------------------------------------------------
------------------------------------- BUTTON 1 -----------------------------------------
------------------------- Alternating Light Bulbs Strobe -------------------------------
----------------------------------------------------------------------------------------
local mastertweentable = {} -- Create the table to store all tweens
local Strobe1 = {}
local Strobe2 = {}
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[1])) do
local tween = TweenService:Create(Lights, TweenInfo[1], {Transparency = .5})
table.insert(Strobe1, tween)
table.insert(mastertweentable, tween) -- Save the tween in mastertweentable
end
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[2])) do
local tween = TweenService:Create(Lights, TweenInfo[1], {Transparency = .5})
table.insert(Strobe2, tween)
table.insert(mastertweentable, tween)
end
Button[1].MouseButton1Click:Connect(function()
warn("Button 1 Pressed")
warn("Cancelling all tweens")
for _, tween in ipairs(mastertweentable) do
tween:Cancel()
end
print("All Tweens Cancelled")
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[3])) do
Lights.Transparency = 0
end
print("All Parts Reset")
for _, tween in ipairs(Strobe1) do
tween:Play()
print("Strobe1 Playing")
end
task.wait(1)
for _, tween in ipairs(Strobe2) do
tween:Play()
print("Strobe2 Playing")
end
end)
----------------------------------------------------------------------------------------
------------------------------------- BUTTON 2 -----------------------------------------
----------------------------- All Light Bulbs Strobe------------------------------------
----------------------------------------------------------------------------------------
local Strobe = {}
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[3])) do
local tween = TweenService:Create(Lights, TweenInfo[1], {Transparency = .5})
table.insert(Strobe, tween)
table.insert(mastertweentable, tween)
end
Button[2].MouseButton1Click:Connect(function()
warn("Button 2 Pressed")
warn("Cancelling all tweens")
for _, tween in ipairs(mastertweentable) do
tween:Cancel()
end
print("All Tweens Cancelled")
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[3])) do
Lights.Transparency = 0
end
print("All Parts Reset")
for _, tween in ipairs(Strobe) do
tween:Play()
print("Strobe Playing")
end
end)
----------------------------------------------------------------------------------------
------------------------------------- BUTTON 3 -----------------------------------------
------------------------- All Light Bulbs Fade Up To Down-------------------------------
----------------------------------------------------------------------------------------
local Rows = {}
for i = 4, 9 do
local Fade = {}
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[i])) do
local tween = TweenService:Create(Lights, TweenInfo[1], {Transparency = .5})
table.insert(Fade, tween)
table.insert(mastertweentable, tween)
end
table.insert(Rows, Fade)
end
Button[3].MouseButton1Click:Connect(function()
warn("Button 3 Pressed")
warn("Cancelling all tweens")
for _, tween in ipairs(mastertweentable) do
tween:Cancel()
end
print("All Tweens Cancelled")
for _, Lights in pairs(CollectionService:GetTagged(Bulbs[3])) do
Lights.Transparency = 0
end
print("All Parts Reset")
for _, Fade in ipairs(Rows) do
for _, tween in ipairs(Fade) do
tween:Play()
print("Fade Playing")
end
local maxDuration = 0
for _, tween in ipairs(Fade) do
maxDuration = math.max(maxDuration, .25)
end
task.wait(maxDuration)
end
end)