local y=game:GetService("\083\101\114\118\101\114\083\116\111\114\097\103\101")local q=require(y.Source.Constants.TileTypes)local g=require(y.Source.Constants.SlopeTypes)return function()local J={}local m=y:FindFirstChild("\084\105\108\101\115")for y,q in pairs(q)do J[q]={}local p=m:FindFirstChild(q)for y,g in pairs(g)do J[q][g]={}local m=p:FindFirstChild(g)if m then for y,m in pairs(m:GetChildren())do local p=m:FindFirstChild("\068\105\102\102\105\099\117\108\116\121")local I=math.clamp(p.Value,0,100)table.insert(J[q][g],{model=m,difficulty=I;type=q})end end end end return J end

local ServerStorage = game:GetService("ServerStorage")

local TileTypes = require(ServerStorage.Source.Constants.TileTypes)
local SlopeTypes = require(ServerStorage.Source.Constants.SlopeTypes)

return function()
	local tileIndex = {}

	local tiles = ServerStorage:FindFirstChild("Tiles")
	for _, tileType in pairs(TileTypes) do
		tileIndex[tileType] = {}

		local tileFolder = tiles:FindFirstChild(tileType)

		for _, slopeType in pairs(SlopeTypes) do
			tileIndex[tileType][slopeType] = {}

			local slopeFolder = tileFolder:FindFirstChild(slopeType)
			if slopeFolder then
				for _, model in pairs(slopeFolder:GetChildren()) do
					local difficultyObject = model:FindFirstChild("Difficulty")

					-- Clamp the difficulty value between 0 and 100 (as it is a percent)
					local difficulty = math.clamp(difficultyObject.Value, 0, 100)

					table.insert(
						tileIndex[tileType][slopeType],
						{
							model = model,
							difficulty = difficulty,
							type = tileType
						}
					)
				end
			end
		end
	end

	return tileIndex
end
