local Q=game:GetService("\080\108\097\121\101\114\115")local h=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local N=require((h:WaitForChild("\080\114\111\106\101\099\116")):WaitForChild("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101"))local H=N:GetResource("\071\097\109\101\068\097\116\097\046\073\116\101\109\046\066\108\111\120\107\105\110\115")local O=N:GetResource("\085\073\046\066\117\116\116\111\110\046\073\109\097\103\101\069\118\101\110\116\066\105\110\100\101\114")local U=N:GetResource("\085\073\046\065\115\112\101\099\116\082\097\116\105\111\083\119\105\116\099\104\101\114")local T=N:GetResource("\083\116\097\116\101\046\068\105\115\112\108\097\121\079\114\100\101\114\067\111\110\116\114\111\108\108\101\114")local J=(N:GetResource("\083\116\097\116\101\046\080\108\097\121\101\114\068\097\116\097")).GetPlayerData(Q.LocalPlayer)local t=Instance.new("\083\099\114\101\101\110\071\117\105")t.Name="\067\111\108\108\101\099\116\097\098\108\101\115\086\105\101\119"t.DisplayOrder=2 t.Parent=script.Parent local P=Instance.new("\073\109\097\103\101\076\097\098\101\108")P.BackgroundTransparency=1 P.Position=UDim2.new(.5,0,1.5,0)P.AnchorPoint=Vector2.new(.5,.5)P.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\050\055\052\053\057\053"P.Parent=t U.new(t,1.4,function()P.Size=UDim2.new(1.26,0,.9,0)P.SizeConstraint=Enum.SizeConstraint.RelativeYY end,function()P.Size=UDim2.new(.9,0,.64285714285714,0)P.SizeConstraint=Enum.SizeConstraint.RelativeXX end)local b=Instance.new("\073\109\097\103\101\076\097\098\101\108")b.BackgroundTransparency=1 b.AnchorPoint=Vector2.new(1,0)b.Size=UDim2.new(.065,0,.065,0)b.SizeConstraint=Enum.SizeConstraint.RelativeYY b.Position=UDim2.new(1,0,0,0)b.ZIndex=4 b.Parent=P local B=O.new(b,UDim2.new(1,0,1,0),"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\048\050\052\056\056","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\048\050\052\051\056","\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\051\048\050\052\054\053")local L=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")L.BackgroundTransparency=1 L.BorderSizePixel=0 L.Position=UDim2.new(.026,0,.036,0)L.Size=UDim2.new(.948,0,.928,0)L.CanvasSize=UDim2.new(1.896,0,0,0)L.ScrollBarThickness=10 L.TopImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\055\048\054\056\051\055\050\048\053"L.MidImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\055\048\054\056\051\054\057\054\048"L.BottomImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\055\048\054\056\051\054\055\052\054"L.Parent=P local K=Instance.new("\073\109\097\103\101\076\097\098\101\108")K.BackgroundColor3=Color3.new(0,0,0)K.BorderSizePixel=0 K.Size=UDim2.new(.5,0,1,0)K.Position=UDim2.new(0,0,0,0)K.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\056\051\052\057\050\051"K.Parent=L local W=Instance.new("\073\109\097\103\101\076\097\098\101\108")W.BackgroundColor3=Color3.new(0,0,0)W.BorderSizePixel=0 W.Size=UDim2.new(.5,0,1,0)W.Position=UDim2.new(.5,0,0,0)W.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\050\050\048\050\056\052\057"W.Parent=L local g={}for Q,h in pairs(H)do local N=Instance.new("\073\109\097\103\101\076\097\098\101\108")N.BackgroundTransparency=1 N.Size=UDim2.new((h.SizeY/2)/600,0,h.SizeY/600,0)N.SizeConstraint="\082\101\108\097\116\105\118\101\089\089"N.Position=UDim2.new(h.PosX/2164,0,h.PosY/600,0)N.Image=h.LockedImage N.Parent=L N.ZIndex=h.PosY+h.SizeY g[Q]=N end local function u()local Q=J:GetValue("\067\111\108\108\101\099\116\101\100\066\108\111\120\107\105\110\115")for h,N in pairs(g)do local O=H[h]N.Image=Q[h]and O.UnlockedImage or O.LockedImage end end u();(J:GetValueChangedSignal("\067\111\108\108\101\099\116\101\100\066\108\111\120\107\105\110\115")):Connect(function()u()end)local q=(script.Parent:WaitForChild("\071\117\105\079\112\101\110\083\116\097\116\101\115")):WaitForChild("\067\111\108\108\101\099\116\097\098\108\101\115")T:Register(t,q)q.Changed:Connect(function()P:TweenPosition(UDim2.new(.5,0,q.Value and.5 or 1.5,0),"\079\117\116","\081\117\097\100",.5,true)end)B.Button.MouseButton1Down:Connect(function()P:TweenPosition(UDim2.new(.5,0,1.5,0),"\079\117\116","\081\117\097\100",.5,true)q.Value=false end)
--[[
TheNexusAvenger

Displays the collectables owned by the player.
--]]

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ReplicatedStorageProject = require(ReplicatedStorage:WaitForChild("Project"):WaitForChild("ReplicatedStorage"))

local Bloxkins = ReplicatedStorageProject:GetResource("GameData.Item.Bloxkins")
local ImageEventBinder = ReplicatedStorageProject:GetResource("UI.Button.ImageEventBinder")
local AspectRatioSwitcher = ReplicatedStorageProject:GetResource("UI.AspectRatioSwitcher")
local DisplayOrderController = ReplicatedStorageProject:GetResource("State.DisplayOrderController")
local PlayerData = ReplicatedStorageProject:GetResource("State.PlayerData").GetPlayerData(Players.LocalPlayer)



--Create the ScreenGui.
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "CollectablesView"
ScreenGui.DisplayOrder = 2
ScreenGui.Parent = script.Parent

--Create the container.
local Background = Instance.new("ImageLabel")
Background.BackgroundTransparency = 1
Background.Position = UDim2.new(0.5,0,1.5,0)
Background.AnchorPoint = Vector2.new(0.5,0.5)
Background.Image = "rbxassetid://131274595"
Background.Parent = ScreenGui

AspectRatioSwitcher.new(ScreenGui,1.4,function()
    Background.Size = UDim2.new(0.9 * 1.4,0,0.9,0)
    Background.SizeConstraint = Enum.SizeConstraint.RelativeYY
end,function()
    Background.Size = UDim2.new(0.9,0,0.9/1.4,0)
    Background.SizeConstraint = Enum.SizeConstraint.RelativeXX
end)

local CloseImage = Instance.new("ImageLabel")
CloseImage.BackgroundTransparency = 1
CloseImage.AnchorPoint = Vector2.new(1,0)
CloseImage.Size = UDim2.new(0.065,0,0.065,0)
CloseImage.SizeConstraint = Enum.SizeConstraint.RelativeYY
CloseImage.Position = UDim2.new(1,0,0,0)
CloseImage.ZIndex = 4
CloseImage.Parent = Background
local CloseButton = ImageEventBinder.new(CloseImage,UDim2.new(1,0,1,0),"rbxassetid://131302488","rbxassetid://131302438","rbxassetid://131302465")

local CollectablesScrollFrame = Instance.new("ScrollingFrame")
CollectablesScrollFrame.BackgroundTransparency = 1
CollectablesScrollFrame.BorderSizePixel = 0
CollectablesScrollFrame.Position = UDim2.new(0.026,0,0.036,0)
CollectablesScrollFrame.Size = UDim2.new(1 - (0.026 * 2),0,1 - (0.036 * 2),0)
CollectablesScrollFrame.CanvasSize = UDim2.new(2 * (1 - (0.026 * 2)),0,0,0)
CollectablesScrollFrame.ScrollBarThickness = 10
CollectablesScrollFrame.TopImage = "rbxassetid://5706837205"
CollectablesScrollFrame.MidImage = "rbxassetid://5706836960"
CollectablesScrollFrame.BottomImage = "rbxassetid://5706836746"
CollectablesScrollFrame.Parent = Background

local BackgroundTexture1 = Instance.new("ImageLabel")
BackgroundTexture1.BackgroundColor3 = Color3.new(0,0,0)
BackgroundTexture1.BorderSizePixel = 0
BackgroundTexture1.Size = UDim2.new(0.5,0,1,0)
BackgroundTexture1.Position = UDim2.new(0,0,0,0)
BackgroundTexture1.Image = "rbxassetid://132834923"
BackgroundTexture1.Parent = CollectablesScrollFrame

local BackgroundTexture2 = Instance.new("ImageLabel")
BackgroundTexture2.BackgroundColor3 = Color3.new(0,0,0)
BackgroundTexture2.BorderSizePixel = 0
BackgroundTexture2.Size = UDim2.new(0.5,0,1,0)
BackgroundTexture2.Position = UDim2.new(0.5,0,0,0)
BackgroundTexture2.Image = "rbxassetid://132202849"
BackgroundTexture2.Parent = CollectablesScrollFrame

--Create the bloxkins.
local BloxkinImages = {}
for BloxkinName,BloxkinData in pairs(Bloxkins) do
    local BloxkinImage = Instance.new("ImageLabel")
    BloxkinImage.BackgroundTransparency = 1
    BloxkinImage.Size = UDim2.new((BloxkinData.SizeY / 2)/600,0,BloxkinData.SizeY/600,0)
    BloxkinImage.SizeConstraint = "RelativeYY"
    BloxkinImage.Position = UDim2.new(BloxkinData.PosX/(1082 * 2),0,BloxkinData.PosY/600,0)
    BloxkinImage.Image = BloxkinData.LockedImage
    BloxkinImage.Parent = CollectablesScrollFrame
    BloxkinImage.ZIndex = BloxkinData.PosY + BloxkinData.SizeY
    BloxkinImages[BloxkinName] = BloxkinImage
end



--[[
Updates the images of the bloxkins.
--]]
local function UpdateBloxkinImages()
    local CollectedBloxkins = PlayerData:GetValue("CollectedBloxkins")
    for BloxkinName,BloxkinImage in pairs(BloxkinImages) do
        local BloxkinData = Bloxkins[BloxkinName]
        BloxkinImage.Image = (CollectedBloxkins[BloxkinName] and BloxkinData.UnlockedImage or BloxkinData.LockedImage)
    end
end



--Connect updating the bloxkins.
UpdateBloxkinImages()
PlayerData:GetValueChangedSignal("CollectedBloxkins"):Connect(function()
    UpdateBloxkinImages()
end)

--Connect opening and closing the window.
local OpenValue = script.Parent:WaitForChild("GuiOpenStates"):WaitForChild("Collectables")
DisplayOrderController:Register(ScreenGui,OpenValue)
OpenValue.Changed:Connect(function()
    Background:TweenPosition(UDim2.new(0.5,0,OpenValue.Value and 0.5 or 1.5,0),"Out","Quad",0.5,true)
end)
CloseButton.Button.MouseButton1Down:Connect(function()
    Background:TweenPosition(UDim2.new(0.5,0,1.5,0),"Out","Quad",0.5,true)
    OpenValue.Value = false
end)