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!
I want to make a tween for multiple parts inside of a model for a layer of a tower. The selected layer will indicate it’s selected by flashing.
What is the issue? Include screenshots / videos if possible!
I can’t turn the tween off for the different tower layers.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried making a function to make the selected layer flash. I added a for loop to the flash function, but I can’t refer to a tween inside of the for loop.
local layerNumber = 1 --this is the layerNumber
local layerAmt = workspace.Tower3:GetChildren()
--tween
local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true)
local goal = {Color = Color3.new(1)}
local tween = ts:Create("parts",info,goal)
------------------------------
local function GetLayerFromNumber(layerN) --layer Names are numbered
local layer = game.workspace.Tower3[layerN]
return layer
end
local function flashStory(layer)
--what I had
for i,v in ipairs(layerAmt) do
local tween = ts:Create(v,info,goal)
tween:play()
end
------------------------------
end
flashStory(GetLayerFromNumber(layerNumber))
upButton.MouseButton1Click:Connect(function() --gui to cycle to the above layer
layerNumber = layerNumber+1
flashStory(GetLayerFromNumber(layerNumber))
end)
This is my first post, sorry for any inconvenience!
You would need to create 2 separate variables for the top layer and bottom layer. You could make a folder/model inside of the Tower3 and name them “TopLayer” and “BottomLayer”
local layerNumber = 1 --this is the layerNumber
local btmlayer = workspace.Tower3.BottomLayer:GetChildren()
local toplayer = workspace.Tower3.TopLayer:GetChildren()
local btmcolor = Color3.fromRGB(255,0,0)
local topcolor = Color3.fromRGB(255,255,255)
--tween
local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true)
local goal = {Color = Color3.new(1)}
local tween = ts:Create("parts",info,goal)
------------------------------
local function GetLayerFromNumber(layerN) --layer Names are numbered
local layer = game.workspace.Tower3[layerN]
return layer
end
local function flashStory(layer)
for i,v in ipairs(btmlayer) do
if btmcolor == Color3.fromRGB(255,255,255) then
btmcolor = Color3.fromRGB(255,0,0)
local tween = ts:Create(v,info,{Color = btmcolor})
tween:play()
else
btmcolor = Color3.fromRGB(255,255,255)
local tween = ts:Create(v,info,{Color = btmcolor})
tween:play()
end
end
for i,v in ipairs(toplayer) do
if topcolor == Color3.fromRGB(255,255,255) then
topcolor = Color3.fromRGB(255,0,0)
local tween = ts:Create(v,info,{Color = topcolor})
tween:play()
else
topcolor = Color3.fromRGB(255,255,255)
local tween = ts:Create(v,info,{Color = topcolor})
tween:play()
end
end
--------------
end
flashStory(GetLayerFromNumber(layerNumber))
upButton.MouseButton1Click:Connect(function() --gui to cycle to the above layer
layerNumber = layerNumber+1
flashStory(GetLayerFromNumber(layerNumber))
end)
Sorry, I am not being clear. I mean that half of the parts in one of the layers is not working. so 1/4 of the entire tower is not functioning correctly.
Ohh, thats my fault. I didn’t do the script completely right, so here’s the fixed version:
local layerNumber = 1 --this is the layerNumber
local btmlayer = workspace.Tower3.BottomLayer:GetChildren()
local toplayer = workspace.Tower3.TopLayer:GetChildren()
local btmcolor = Color3.fromRGB(255,0,0)
local topcolor = Color3.fromRGB(255,255,255)
--tween
local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true)
local goal = {Color = Color3.new(1)}
local tween = ts:Create("parts",info,goal)
------------------------------
local function GetLayerFromNumber(layerN) --layer Names are numbered
local layer = game.workspace.Tower3[layerN]
return layer
end
local function flashStory(layer)
for i,v in ipairs(btmlayer) do
local tween = ts:Create(v,info,{Color = btmcolor})
tween:play()
end
if btmcolor == Color3.fromRGB(255,255,255) then
btmcolor = Color3.fromRGB(255,0,0)
else
btmcolor =Color3.fromRGB(255,255,255)
end
for i,v in ipairs(toplayer) do
local tween = ts:Create(v,info,{Color = topcolor})
tween:play()
end
if topcolor == Color3.fromRGB(255,255,255) then
topcolor = Color3.fromRGB(255,0,0)
else
topcolor =Color3.fromRGB(255,255,255)
end
--------------
end
flashStory(GetLayerFromNumber(layerNumber))
upButton.MouseButton1Click:Connect(function() --gui to cycle to the above layer
layerNumber = layerNumber+1
flashStory(GetLayerFromNumber(layerNumber))
end)
Also sorry for late response, I’m cleaning my jacuzzi rn
That is the solution with a minor mistake. After some research, I found that it’s tween:Cancel() and not tween:Stop(). If you fix that I will mark your response as solution