local t=replicatedStorage.Game.Powerups local P=game.ReplicatedStorage.MapSettings.Powerups local W=TweenInfo.new(1,Enum.EasingStyle.Sine)local Y=maxAmmoFrame:GetDescendants()local b={}for t,P in pairs(Y)do local W=nil if P:IsA("\073\109\097\103\101\076\097\098\101\108")then W={INSTANCE=P,PROPERTY="\073\109\097\103\101\084\114\097\110\115\112\097\114\101\110\099\121",OFF={ImageTransparency=1};ORIGINAL={ImageTransparency=P.ImageTransparency}}elseif P:IsA("\070\114\097\109\101")then W={INSTANCE=P,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=P.BackgroundTransparency}}elseif P:IsA("\084\101\120\116\076\097\098\101\108")then W={INSTANCE=P,PROPERTY="\084\101\120\116\084\114\097\110\115\112\097\114\101\110\099\121";OFF={TextTransparency=1},ORIGINAL={TextTransparency=P.TextTransparency}}else continue end table.insert(b,W)end table.insert(b,{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 i=4 local D=0 local function e()D+=1 maxAmmoFrame.Visible=true for t,P in pairs(b)do local W=P.INSTANCE local Y=P.PROPERTY W[Y]=1 end for t,P in pairs(b)do local Y=P.INSTANCE local b=P.ORIGINAL;(tweenService:Create(Y,W,b)):Play()end local t=tick()repeat wait()until tick()-t>i or D>1 if D>1 then D-=1 return end for t,P in pairs(b)do local Y=P.INSTANCE local b=P.OFF;(tweenService:Create(Y,W,b)):Play()end local P=tick()repeat wait()until tick()-P>1 or D>1 if D>1 then D-=1 return end maxAmmoFrame.Visible=false D-=1 end local function h(t)if t.Name=="\077\097\120\065\109\109\111"then e()end end P.ChildAdded:Connect(h)

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)


