local C=function()for C,e in pairs(Content:GetChildren())do if e~=UIGrid then e:Destroy()end end end local e=function(C)local e=(C:GetChildren())[1]assert(e,"\091\069\114\114\111\114\093 \067\104\097\114\097\099\116\101\114 \100\111\101\115\110\'\116 \101\120\105\115\116 \105\110 \109\111\100\117\108\101 "..C.Name)local s=Instance.new("\086\105\101\119\112\111\114\116\070\114\097\109\101")s.Name=C.Name s.Parent=Content s.BorderSizePixel=0 s.BackgroundColor3=Color3.fromRGB(25,25,25)local B=(game.ServerStorage.Extra:WaitForChild("\085\073\067\111\114\110\101\114")):Clone()B.Parent=s local l=e:Clone()l.Parent=s local A=Instance.new("\067\097\109\101\114\097")A.Parent=s A.CFrame=CFrame.new(((l:WaitForChild("\072\101\097\100")).CFrame*CFrame.new(0,0,-8)).Position+Vector3.new(3,-2,0),l.Head.Position)A.FieldOfView=30 s.CurrentCamera=A local E=Instance.new("\084\101\120\116\066\117\116\116\111\110")E.Parent=s E.Size=UDim2.new(1,0,1,0)E.BackgroundTransparency=1 E.Text=""E.MouseButton1Click:Connect(function()if Debounce then return end Debounce=true SelectedCharacter.Value=C wait(1)Debounce=false end)end local s=function()C()local s=GetCellSize:InvokeClient(Player)UIGrid.CellSize=UDim2.new(0,s,0,s)for C,s in pairs(Characters:GetChildren())do e(s)end end s()
-- Functions
local Clear = function()
	for _, v in pairs(Content:GetChildren()) do
		if v ~= UIGrid then
			v:Destroy()
		end
	end
end

local Add = function(char)
	local charPrev = char:GetChildren()[1]
	assert(charPrev, "[Error] Character doesn't exist in module " .. char.Name)

	-- base frame
	local ViewportFrame = Instance.new("ViewportFrame")
	ViewportFrame.Name = char.Name
	ViewportFrame.Parent = Content
	ViewportFrame.BorderSizePixel = 0
	ViewportFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
	local Uicorner = game.ServerStorage.Extra:WaitForChild("UICorner"):Clone()
	Uicorner.Parent = ViewportFrame

	-- character preview
	local clone = charPrev:Clone()
	clone.Parent = ViewportFrame

	-- camera
	local camera = Instance.new("Camera")
	camera.Parent = ViewportFrame
	camera.CFrame = CFrame.new(
		(clone:WaitForChild("Head").CFrame * CFrame.new(0, 0, -8)).Position + Vector3.new(3, -2, 0),
		clone.Head.Position
	)
	camera.FieldOfView = 30

	ViewportFrame.CurrentCamera = camera

	-- button
	local button = Instance.new("TextButton")
	button.Parent = ViewportFrame
	button.Size = UDim2.new(1, 0, 1, 0)
	button.BackgroundTransparency = 1
	button.Text = ""

	button.MouseButton1Click:Connect(function()
		if Debounce then
			return
		end
		Debounce = true
		SelectedCharacter.Value = char
		wait(1)
		Debounce = false
	end)
end

local Refresh = function()
	Clear()
	local cellsize = GetCellSize:InvokeClient(Player)
	UIGrid.CellSize = UDim2.new(0, cellsize, 0, cellsize)
	for _, v in pairs(Characters:GetChildren()) do
		Add(v)
	end
end

Refresh()
