basically, i have a local script that works fine without the loop, but breaks with the loop. however, i need the loop so i can animate a static ui
code:
local Static_Index = 5
local Static_Elements = {
Frame.Frame_1,
Frame.Frame_2,
Frame.Frame_3,
Frame.Frame_4,
Frame.Frame_5
}
local function StartStatic()
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0 )
local tween1 = TweenService:Create(Frame.Frame_1, tweenInfo, {ImageTransparency = 0})
local tween2 = TweenService:Create(Frame.Frame_2, tweenInfo, {ImageTransparency = 0})
local tween3 = TweenService:Create(Frame.Frame_3, tweenInfo, {ImageTransparency = 0})
local tween4 = TweenService:Create(Frame.Frame_4, tweenInfo, {ImageTransparency = 0})
local tween5 = TweenService:Create(Frame.Frame_5, tweenInfo, {ImageTransparency = 0})
tween1:Play()
tween2:Play()
tween3:Play()
tween4:Play()
tween5:Play()
while task.wait(.05) do --THIS LOOP RIGHT HERE
for index, Static in ipairs(Static_Elements) do
Static_Elements[Static_Index].Visible = false
Static.Visible = true
Static_Index = index
end
end--]]
end
local function StopStatic()
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0 )
local tween1 = TweenService:Create(Frame.Frame_1, tweenInfo, {ImageTransparency = 1})
local tween2 = TweenService:Create(Frame.Frame_2, tweenInfo, {ImageTransparency = 1})
local tween3 = TweenService:Create(Frame.Frame_3, tweenInfo, {ImageTransparency = 1})
local tween4 = TweenService:Create(Frame.Frame_4, tweenInfo, {ImageTransparency = 1})
local tween5 = TweenService:Create(Frame.Frame_5, tweenInfo, {ImageTransparency = 1})
tween1:Play()
tween2:Play()
tween3:Play()
tween4:Play()
tween5:Play()
end
HitByBat.OnClientEvent:Connect(function()
StartStatic()
task.wait(3)
StopStatic()
end)
(i deleted unneccisary parts)