local q=replicatedStorage.Game.Powerups local w=game.ReplicatedStorage.MapSettings.Powerups local M=TweenInfo.new(1,Enum.EasingStyle.Sine)local Q=maxAmmoFrame:GetDescendants()local z={}for q,w in pairs(Q)do local M=nil if w:IsA("\073\109\097\103\101\076\097\098\101\108")then M={INSTANCE=w;PROPERTY="\073\109\097\103\101\084\114\097\110\115\112\097\114\101\110\099\121",OFF={ImageTransparency=1};ORIGINAL={ImageTransparency=w.ImageTransparency}}elseif w:IsA("\070\114\097\109\101")then M={INSTANCE=w;PROPERTY="\066\097\099\107\103\114\111\117\110\100\084\114\097\110\115\112\097\114\101\110\099\121";OFF={BackgroundTransparency=1},ORIGINAL={BackgroundTransparency=w.BackgroundTransparency}}elseif w:IsA("\084\101\120\116\076\097\098\101\108")then M={INSTANCE=w,PROPERTY="\084\101\120\116\084\114\097\110\115\112\097\114\101\110\099\121",OFF={TextTransparency=1},ORIGINAL={TextTransparency=w.TextTransparency}}else continue end table.insert(z,M)end table.insert(z,{INSTANCE=maxAmmoFrame,PROPERTY="\073\109\097\103\101\084\114\097\110\115\112\097\114\101\110\099\121";OFF={ImageTransparency=1},ORIGINAL={ImageTransparency=maxAmmoFrame.ImageTransparency}})local b=4 local g=0 local function J()g+=1 maxAmmoFrame.Visible=true for q,w in pairs(z)do local M=w.INSTANCE local Q=w.PROPERTY M[Q]=1 end for q,w in pairs(z)do local Q=w.INSTANCE local z=w.ORIGINAL;(tweenService:Create(Q,M,z)):Play()end local q=tick()repeat wait()until tick()-q>b or g>1 if g>1 then g-=1 return end for q,w in pairs(z)do local Q=w.INSTANCE local z=w.OFF;(tweenService:Create(Q,M,z)):Play()end local w=tick()repeat wait()until tick()-w>1 or g>1 if g>1 then g-=1 return end maxAmmoFrame.Visible=false g-=1 end local function V(q)if q.Name=="\077\097\120\065\109\109\111"then J()end end w.ChildAdded:Connect(V)
-- folders
local powerupsFolder = replicatedStorage.Game.Powerups
local mapActivePowerupsFolder = game.ReplicatedStorage.MapSettings.Powerups

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine)

local descendants = maxAmmoFrame:GetDescendants()
local instanceInfoTables = {}

for _, item in pairs(descendants) do
	local infoTable = nil
	if item:IsA("ImageLabel") then
		infoTable = {
			INSTANCE = item,
			PROPERTY = "ImageTransparency",
			OFF = { ImageTransparency = 1 },
			ORIGINAL = { ImageTransparency = item["ImageTransparency"] },
		}
	elseif item:IsA("Frame") then
		infoTable = {
			INSTANCE = item,
			PROPERTY = "BackgroundTransparency",
			OFF = { BackgroundTransparency = 1 },
			ORIGINAL = { BackgroundTransparency = item["BackgroundTransparency"] },
		}
	elseif item:IsA("TextLabel") then
		infoTable = {
			INSTANCE = item,
			PROPERTY = "TextTransparency",
			OFF = { TextTransparency = 1 },
			ORIGINAL = { TextTransparency = item["TextTransparency"] },
		}
	else
		continue
	end
	table.insert(instanceInfoTables, infoTable)
end
table.insert(
	instanceInfoTables,
	{
		INSTANCE = maxAmmoFrame,
		PROPERTY = "ImageTransparency",
		OFF = { ImageTransparency = 1 },
		ORIGINAL = { ImageTransparency = maxAmmoFrame["ImageTransparency"] },
	}
)

local VisibleTime = 4
local Queue = 0
local function updateCard()
	Queue += 1
	maxAmmoFrame.Visible = true

	-- off
	for _, infoTable in pairs(instanceInfoTables) do
		local instance = infoTable["INSTANCE"]
		local property = infoTable["PROPERTY"]
		instance[property] = 1
	end

	-- on
	for _, infoTable in pairs(instanceInfoTables) do
		local instance = infoTable["INSTANCE"]
		local original = infoTable["ORIGINAL"]
		tweenService:Create(instance, tweenInfo, original):Play()
	end

	local start = tick()
	repeat
		wait()
	until (tick() - start) > VisibleTime or Queue > 1
	if Queue > 1 then
		Queue -= 1
		return
	end

	-- off
	for _, infoTable in pairs(instanceInfoTables) do
		local instance = infoTable["INSTANCE"]
		local off = infoTable["OFF"]
		tweenService:Create(instance, tweenInfo, off):Play()
	end

	local start = tick()
	repeat
		wait()
	until (tick() - start) > 1 or Queue > 1
	if Queue > 1 then
		Queue -= 1
		return
	end

	maxAmmoFrame.Visible = false
	Queue -= 1
end

local function powerUpAdded(powerUp)
	if powerUp.Name == "MaxAmmo" then
		updateCard()
	end
end
mapActivePowerupsFolder.ChildAdded:Connect(powerUpAdded)
