local indexMenu = script.Parent
local collected = indexMenu:WaitForChild("CubesCollected")
local mainFrame = indexMenu:WaitForChild("MainFrame")
local scrollingFrame = mainFrame:WaitForChild("List")
local UIGridLayout = scrollingFrame:WaitForChild("UIGridLayout")
local info = mainFrame:WaitForChild("CubeInfo")
local difficultiesFrame = mainFrame:WaitForChild("DifficultyChart")
local Players = game:GetService('Players')
local player = Players.LocalPlayer
local cubesCollected = player:WaitForChild("cubesCollected")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local cubesFile = ReplicatedStorage:WaitForChild("Cubes")
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0)
local tweenClose = tweenService:Create(indexMenu, tweenInfo, {Position = UDim2.new(0.5, 0, 1.5, 0)})
local filterType = Instance.new("StringValue", player)
filterType.Name = "filterType"
filterType.Value = "All"
local difficultyColors = {
Color3.fromHex("#a7ffa2"), -- Beginner
Color3.fromHex("#00e300"), -- Easy
Color3.fromHex("#ffff00"), -- Medium
Color3.fromHex("#ff9d00"), -- Hard
Color3.fromHex("#e10000"), -- Difficult
Color3.fromHex("#790000"), -- Challenging
Color3.fromHex("#000000"), -- Intense
Color3.fromHex("#ff00ea"), -- Remorseless
Color3.fromHex("#0003c8"), -- Insane
Color3.fromHex("#0082c8"), -- Extreme
Color3.fromHex("#00fbff"), -- Terrifying
Color3.fromHex("#ffffff"), -- Catastrophic
}
local difficulties = {
"Beginner",
"Easy",
"Medium",
"Hard",
"Difficult",
"Challenging",
"Intense",
"Remorseless",
"Insane",
"Extreme",
"Terrifying",
"Catastrophic",
}
local areaColors = {
Color3.fromHex("#b97619"), -- Cube Town
}
local areas = {
"Cube Town",
}
local filters = {
"Owned",
"Unowned",
}
local totalCount = 0
for i, v in pairs(cubesFile:GetChildren()) do
totalCount = totalCount + 1
end
local collectedCount = 0
for i, v in pairs(cubesCollected:GetChildren()) do
collectedCount = collectedCount + 1
end
collected.Text = collectedCount.."/"..totalCount.." Collected (".. math.round((collectedCount / totalCount) * 100) .."%)"
script.Parent.Parent.ActivateIt.TextLabel.Text = collectedCount.."/"..totalCount.." (".. math.round((collectedCount / totalCount) * 100) .."%)"
for i, item in pairs(cubesFile:GetChildren()) do
local itemName = item.Name
local difficulty = item.difficulty.Value
local hint = item.hint.Value
local name = item.name.Value
local description = item.description.Value
local area = item.area.Value
local creator = item.creator.Value
local itemButton = script.TemplateCube:Clone()
itemButton.Parent = scrollingFrame
itemButton.Name = itemName
itemButton.Difficulty.BackgroundColor3 = difficultyColors[difficulty]
itemButton.BackgroundColor3 = difficultyColors[difficulty]
itemButton.CubeName.Text = name
if cubesCollected:FindFirstChild(itemName) then
itemButton.ViewportFrame.ImageColor3 = Color3.new(1, 1, 1)
itemButton.ViewportFrame.ImageTransparency = 0
else
itemButton.ViewportFrame.ImageColor3 = Color3.new(0.15, 0.15, 0.15)
itemButton.ViewportFrame.ImageTransparency = 0.5
end
for i, folder in pairs(workspace.CubeModels:GetChildren()) do
for i, cube in pairs(folder:GetChildren()) do
if itemButton.ViewportFrame:FindFirstChild(cube.Name) then
itemButton.ViewportFrame:FindFirstChild(cube.Name):Destroy()
end
end
end
local VPclone = nil
for i, folder in pairs(workspace.CubeModels:GetChildren()) do
VPclone = folder:FindFirstChild(itemButton.Name):Clone()
end
VPclone.Parent = itemButton.ViewportFrame
if VPclone:IsA("Part") then
VPclone.Position = Vector3.new(152, -9.421, 56.31)
VPclone.Orientation = Vector3.new(0, -180, 0)
else
VPclone:SetPrimaryPartCFrame(CFrame.new(152, -9.421, 56.31) * CFrame.Angles(0, math.rad(-180), 0))
end
itemButton.LayoutOrder = difficulty
itemButton.CubeNum.Text = #cubesFile:GetChildren() - (#cubesFile:GetChildren() - i)
UIGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
UIGridLayout:ApplyLayout()
itemButton.Button.MouseButton1Click:Connect(function()
script.Sound:Play()
for i, folder in pairs(workspace.CubeModels:GetChildren()) do
for i, cube in pairs(folder:GetChildren()) do
if info.ViewportFrame:FindFirstChild(cube.Name) then
info.ViewportFrame:FindFirstChild(cube.Name):Destroy()
end
end
end
local VPclone2 = nil
for i, folder in pairs(workspace.CubeModels:GetChildren()) do
VPclone2 = folder:FindFirstChild(itemButton.Name):Clone()
end
VPclone2.Parent = info.ViewportFrame
if VPclone2:IsA("Part") then
VPclone2.Position = Vector3.new(152, -9.421, 56.31)
VPclone2.Orientation = Vector3.new(0, -180, 0)
else
VPclone2:SetPrimaryPartCFrame(CFrame.new(152, -9.421, 56.31) * CFrame.Angles(0, math.rad(-180), 0))
end
info.CubeName.Text = name
info.CubeHint.ScrollingFrame.Text.Text = "Hint: "..hint
info.Difficulty.BackgroundColor3 = difficultyColors[difficulty]
info.CubeDesc.ScrollingFrame.Text.Text = description
info.Difficulty.Text = difficulties[difficulty]
info.Area.Text = areas[area]
info.Area.BackgroundColor3 = areaColors[area]
info.Creator.Text = "Made By : "..creator
scrollingFrame.Visible = false
difficultiesFrame.Visible = false
info.Visible = true
end)
end
cubesCollected.ChildAdded:Connect(function(child)
collectedCount = collectedCount + 1
collected.Text = collectedCount.."/"..totalCount.." Collected (".. math.round((collectedCount / totalCount) * 100) .."%)"
script.Parent.Parent.ActivateIt.TextLabel.Text = collectedCount.."/"..totalCount.." (".. math.round((collectedCount / totalCount) * 100) .."%)"
local childButton = scrollingFrame:FindFirstChild(child.Name)
childButton.ViewportFrame.ImageColor3 = Color3.new(1, 1, 1)
childButton.ViewportFrame.ImageTransparency = 0
childButton.LayoutOrder = cubesFile:FindFirstChild(child.Name).difficulty.Value
--childButton.CubeNum.Text = child.LayoutOrder
end)