--!nocheck --[[ Blocks UI · by Blocky Studios A brick-styled, client-side UI library for Roblox. Put this ModuleScript in ReplicatedStorage and require it from a LocalScript, or run the raw source: local Blocks = loadstring(source)() See README.md / Example.client.luau for the full API. ]] local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") local UserInputService = game:GetService("UserInputService") local HttpService = game:GetService("HttpService") local TextService = game:GetService("TextService") local GuiService = game:GetService("GuiService") local ContextActionService = game:GetService("ContextActionService") local RunService = game:GetService("RunService") local Blocks = { Version = "1.3.0", Flags = {}, _items = {}, _themed = {}, _windows = {} } ---------------------------------------------------------------------- -- Style ---------------------------------------------------------------------- local rgb = Color3.fromRGB local WHITE = rgb(255, 255, 255) local INK = rgb(14, 14, 16) -- outlines / shadows local BODY = ColorSequence.new(rgb(64, 64, 68), rgb(52, 52, 56)) local ROW = rgb(82, 82, 87) local SLOT = rgb(28, 28, 31) -- recessed areas local SUB = rgb(198, 198, 202) local GREEN = rgb(88, 178, 56) local RED = rgb(204, 52, 46) local YELLOW = rgb(248, 202, 58) local GREY = rgb(128, 128, 134) local FONT = Font.new("rbxassetid://12187371840", Enum.FontWeight.Bold) -- Silkscreen (pixel font) local TEXT_SCALE = 0.92 local HEADER_H = 46 local SIDEBAR_W = 184 Blocks.Themes = { Grass = { Accent = rgb(92, 172, 54) }, Dirt = { Accent = rgb(150, 104, 70) }, Stone = { Accent = rgb(132, 132, 138) }, Diamond = { Accent = rgb(66, 206, 204) }, Gold = { Accent = rgb(246, 198, 52) }, Redstone = { Accent = rgb(214, 44, 34) }, Emerald = { Accent = rgb(36, 196, 98) }, Lapis = { Accent = rgb(52, 92, 204) }, Amethyst = { Accent = rgb(152, 102, 222) }, } Blocks.Theme = Blocks.Themes.Grass Blocks.Icon = "rbxassetid://78097810082984" -- Blocky Studios block; set Blocks.Icon or pass Icon to CreateWindow ---------------------------------------------------------------------- -- Helpers ---------------------------------------------------------------------- local function new(class, props, children) local o = Instance.new(class) for k, v in pairs(props) do if k ~= "Parent" then o[k] = v end end if children then for _, c in ipairs(children) do c.Parent = o end end o.Parent = props.Parent return o end local function corner(r) return new("UICorner", { CornerRadius = UDim.new(0, 0) }) end local function stroke(t, color) return new("UIStroke", { Thickness = t or 3, Color = color or INK, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, LineJoinMode = Enum.LineJoinMode.Miter, }) end -- Pixel shading: two flat bands, lighter on top and darker below. local function hueSeq(c) local h, s, v = c:ToHSV() local top = Color3.fromHSV(h, s * 0.9, math.clamp(v * 1.1, 0, 1)) local bot = Color3.fromHSV(h, math.clamp(s * 1.04, 0, 1), v * 0.84) return ColorSequence.new({ ColorSequenceKeypoint.new(0, top), ColorSequenceKeypoint.new(0.5, top), ColorSequenceKeypoint.new(0.501, bot), ColorSequenceKeypoint.new(1, bot), }) end local function tw(obj, t, props, style, dir) local tween = TweenService:Create( obj, TweenInfo.new(t, style or Enum.EasingStyle.Quad, dir or Enum.EasingDirection.Out), props ) tween:Play() return tween end local function text(parent, props) local thickness = math.max(1, (props.Stroke or 2) * 0.6) props.Stroke = nil local base = { BackgroundTransparency = 1, FontFace = FONT, TextColor3 = WHITE, TextSize = 16, TextXAlignment = Enum.TextXAlignment.Left, TextTruncate = Enum.TextTruncate.AtEnd, Parent = parent, } for k, v in pairs(props) do base[k] = v end base.TextSize = math.floor(base.TextSize * TEXT_SCALE + 0.5) local label = new("TextLabel", base) new("UIStroke", { Thickness = thickness, Color = INK, LineJoinMode = Enum.LineJoinMode.Miter, Parent = label }) return label end -- Pixel texture: sparse light and dark squares, like a block face. local function studs(parent, w, h, pitch) pitch = 8 local holder = new("Frame", { Name = "Pixels", BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), ClipsDescendants = true, Parent = parent, }) local rng = Random.new(math.floor(w * 31 + h * 7)) local cols, rows = math.ceil(w / pitch), math.ceil(h / pitch) for y = 0, rows - 1 do for x = 0, cols - 1 do if rng:NextNumber() < 0.2 then new("Frame", { BackgroundColor3 = rng:NextNumber() < 0.5 and WHITE or rgb(0, 0, 0), BackgroundTransparency = rng:NextNumber(0.84, 0.93), BorderSizePixel = 0, Position = UDim2.fromOffset(x * pitch, y * pitch), Size = UDim2.fromOffset(pitch, pitch), Parent = holder, }) end end end return holder end local function themed(fn) table.insert(Blocks._themed, fn) fn(Blocks.Theme) end local function resolveColor(c, theme) if typeof(c) == "Color3" then return c elseif c == "Green" then return GREEN elseif c == "Red" then return RED elseif c == "Grey" then return GREY elseif c == "Yellow" then return YELLOW end return theme.Accent end -- A solid brick: white frame + hue gradient + ink outline. local function brick(class, props, color, strokeT) props.BackgroundColor3 = WHITE props.BorderSizePixel = 0 if class == "TextButton" then props.AutoButtonColor = false props.Text = "" end local f = new(class, props, { corner(6), stroke(strokeT or 3) }) local g = new("UIGradient", { Rotation = 90, Parent = f }) themed(function(t) g.Color = hueSeq(resolveColor(color, t)) end) -- hard bevel: lit top edge, shaded bottom edge new("Frame", { Name = "BevelTop", BackgroundColor3 = WHITE, BackgroundTransparency = 0.62, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, 2), ZIndex = props.ZIndex or 1, Parent = f, }) new("Frame", { Name = "BevelBottom", BackgroundColor3 = rgb(0, 0, 0), BackgroundTransparency = 0.68, BorderSizePixel = 0, AnchorPoint = Vector2.new(0, 1), Position = UDim2.fromScale(0, 1), Size = UDim2.new(1, 0, 0, 3), ZIndex = props.ZIndex or 1, Parent = f, }) return f, g end local function isPress(input) return input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch end local function isMove(input) return input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch end -- Calls fn(xFraction, yFraction) while the pointer is held on target. local function onDrag(maid, target, fn) local dragging = false local function update(input) local p, s = target.AbsolutePosition, target.AbsoluteSize fn(math.clamp((input.Position.X - p.X) / s.X, 0, 1), math.clamp((input.Position.Y - p.Y) / s.Y, 0, 1)) end table.insert(maid, target.InputBegan:Connect(function(input) if isPress(input) then dragging = true update(input) end end)) table.insert(maid, UserInputService.InputChanged:Connect(function(input) if dragging and isMove(input) then update(input) end end)) table.insert(maid, UserInputService.InputEnded:Connect(function(input) if isPress(input) then dragging = false end end)) end local function pressable(button, face) face = face or button local rest = face.Position button.MouseButton1Down:Connect(function() tw(face, 0.06, { Position = rest + UDim2.fromOffset(0, 3) }) end) local function up() tw(face, 0.1, { Position = rest }) end button.MouseButton1Up:Connect(up) button.MouseLeave:Connect(up) end -- Drag target by pressing handle, with mouse or touch. Follows only the finger that started -- the drag, keeps the handle on screen, and reports whether the press turned into a drag -- (state.Moved) so a button can tell a tap from a drag. local function draggable(maid, handle, target, onStart, onEnd) local state = { Moved = false, Enabled = true } local active, startInput, startPos handle.InputBegan:Connect(function(input) if isPress(input) then state.Moved = false -- reset on every press, so a locked button still counts taps if not state.Enabled then return end active, startInput, startPos = input, input.Position, target.Position if onStart then onStart() end end end) table.insert(maid, UserInputService.InputChanged:Connect(function(input) if not active then return end local same = input == active or (active.UserInputType == Enum.UserInputType.MouseButton1 and input.UserInputType == Enum.UserInputType.MouseMovement) if not same then return end local d = input.Position - startInput if not state.Moved and d.Magnitude < 6 then return end state.Moved = true target.Position = startPos + UDim2.fromOffset(d.X, d.Y) -- keep the handle inside the screen local gui = handle:FindFirstAncestorWhichIsA("ScreenGui") if gui then local screen, p, size = gui.AbsoluteSize, handle.AbsolutePosition, handle.AbsoluteSize local fx = math.clamp(p.X, 0, math.max(0, screen.X - size.X)) - p.X local fy = math.clamp(p.Y, 0, math.max(0, screen.Y - size.Y)) - p.Y if fx ~= 0 or fy ~= 0 then target.Position += UDim2.fromOffset(fx, fy) end end end)) table.insert(maid, UserInputService.InputEnded:Connect(function(input) if active and (input == active or (active.UserInputType == Enum.UserInputType.MouseButton1 and input.UserInputType == Enum.UserInputType.MouseButton1)) then active = nil if onEnd then onEnd(state.Moved) end end end)) return state end ---------------------------------------------------------------------- -- Input: keyboard, controller / console and touch ---------------------------------------------------------------------- local PAD_NAMES = { ButtonA = "A", ButtonB = "B", ButtonX = "X", ButtonY = "Y", ButtonL1 = "LB", ButtonR1 = "RB", ButtonL2 = "LT", ButtonR2 = "RT", ButtonL3 = "LS", ButtonR3 = "RS", ButtonStart = "Start", ButtonSelect = "View", DPadUp = "Up", DPadDown = "Down", DPadLeft = "Left", DPadRight = "Right", Thumbstick1 = "L Stick", Thumbstick2 = "R Stick", } local function isPadKey(key) return typeof(key) == "EnumItem" and key.EnumType == Enum.KeyCode and PAD_NAMES[key.Name] ~= nil end local function usingGamepad() return string.sub(UserInputService:GetLastInputType().Name, 1, 7) == "Gamepad" end local function touchOnly() return UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled end local function keyName(key) if not key then return "None" end if PAD_NAMES[key.Name] then return PAD_NAMES[key.Name] end local ok, str = pcall(UserInputService.GetStringForKeyCode, UserInputService, key) if ok and str and #str <= 2 and string.find(str, "%S") then return string.upper(str) -- matches the player's keyboard layout (AZERTY etc.) end return key.Name end -- A key or button picture. Controller buttons use the platform's own art (Xbox or -- PlayStation, chosen by Roblox for the connected pad); keyboard keys get a key cap. local function glyph(parent, key, size, props) local holder = new("Frame", { BackgroundTransparency = 1, Size = UDim2.fromOffset(size, size), Parent = parent }) for k, v in pairs(props or {}) do holder[k] = v end local image = "" if isPadKey(key) then local ok, img = pcall(UserInputService.GetImageForKeyCode, UserInputService, key) image = ok and img or "" end if image ~= "" then new("ImageLabel", { BackgroundTransparency = 1, Image = image, Size = UDim2.fromScale(1, 1), Parent = holder }) else local name = keyName(key) holder.Size = UDim2.fromOffset(math.max(size, #name * size * 0.42 + 10), size) local cap = brick("Frame", { Size = UDim2.fromScale(1, 1), Parent = holder }, "Grey", 2) text(cap, { Text = name, Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = math.floor(size * 0.5), Stroke = 1.5, }) end return holder end -- True when obj and all its parents up to stop are visible. local function shown(obj, stop) while obj and obj ~= stop do if obj:IsA("GuiObject") and not obj.Visible then return false end obj = obj.Parent end return true end -- Keeps controller selection inside a frame (windows, dialogs, popups). local function trapSelection(frame) frame.SelectionGroup = true frame.SelectionBehaviorUp = Enum.SelectionBehavior.Stop frame.SelectionBehaviorDown = Enum.SelectionBehavior.Stop frame.SelectionBehaviorLeft = Enum.SelectionBehavior.Stop frame.SelectionBehaviorRight = Enum.SelectionBehavior.Stop end -- Pixel outline drawn around whatever the controller has selected. local function selectionImage() local f = new("Frame", { Name = "BlocksSelection", BackgroundTransparency = 1, Position = UDim2.fromOffset(-5, -5), Size = UDim2.new(1, 10, 1, 10), }, { stroke(3, WHITE) }) new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(3, 3), Size = UDim2.new(1, -6, 1, -6), Parent = f, }, { stroke(2, INK) }) return f end -- D-pad adjusting for sliders and the colour picker while a controller has them selected. -- Held directions repeat. The thumbstick still moves selection away. local adjusters = setmetatable({}, { __mode = "k" }) local adjustHooked = false local function gamepadAdjust(obj, axisX, axisY, step) adjusters[obj] = { X = axisX, Y = axisY, Step = step } if adjustHooked then return end adjustHooked = true local run = 0 Blocks._adjustConn = GuiService:GetPropertyChangedSignal("SelectedObject"):Connect(function() ContextActionService:UnbindAction("BlocksUI_Adjust") run += 1 local selected = GuiService.SelectedObject local a = selected and adjusters[selected] if not a then return end local keys = {} if a.X then table.insert(keys, Enum.KeyCode.DPadLeft) table.insert(keys, Enum.KeyCode.DPadRight) end if a.Y then table.insert(keys, Enum.KeyCode.DPadUp) table.insert(keys, Enum.KeyCode.DPadDown) end ContextActionService:BindActionAtPriority("BlocksUI_Adjust", function(_, state, input) if state == Enum.UserInputState.Begin then local k = input.KeyCode local dx = (k == Enum.KeyCode.DPadRight and 1) or (k == Enum.KeyCode.DPadLeft and -1) or 0 local dy = (k == Enum.KeyCode.DPadDown and 1) or (k == Enum.KeyCode.DPadUp and -1) or 0 a.Step(dx, dy) run += 1 local mine = run task.delay(0.35, function() while run == mine and GuiService.SelectedObject == selected do a.Step(dx, dy) task.wait(0.05) end end) else run += 1 end return Enum.ContextActionResult.Sink end, false, Enum.ContextActionPriority.High.Value + 20, table.unpack(keys)) end) end -- AutomaticCanvasSize is unreliable under UIScale, so the canvas is sized by hand. local function autoCanvas(scroll, pad, gap) local function update() local total, count = pad, 0 local k = 1 local scaleSource = scroll:FindFirstAncestorWhichIsA("ScreenGui") local node = scroll while node and node ~= scaleSource do local sc = node:FindFirstChildOfClass("UIScale") if sc then k *= sc.Scale end node = node.Parent end for _, child in ipairs(scroll:GetChildren()) do if child:IsA("GuiObject") and child.Visible then total += child.AbsoluteSize.Y / k count += 1 end end total += math.max(0, count - 1) * gap scroll.CanvasSize = UDim2.fromOffset(0, total) end local function hook(child) if child:IsA("GuiObject") then child:GetPropertyChangedSignal("AbsoluteSize"):Connect(update) child:GetPropertyChangedSignal("Visible"):Connect(update) end update() end scroll.ChildAdded:Connect(hook) scroll.ChildRemoved:Connect(function() task.defer(update) end) for _, child in ipairs(scroll:GetChildren()) do hook(child) end end local function getGui(name, order) local pg = Players.LocalPlayer:WaitForChild("PlayerGui") local gui = pg:FindFirstChild(name) if not gui then gui = new("ScreenGui", { Name = name, ResetOnSpawn = false, DisplayOrder = order, ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = pg, }) end return gui end local function viewportScale() local cam = workspace.CurrentCamera local v = cam and cam.ViewportSize or Vector2.new(1280, 720) local s = math.clamp(math.min(v.X / 900, v.Y / 560), 0.55, 1.15) if GuiService:IsTenFootInterface() then s = math.min(s * 1.25, 1.45) -- consoles on a TV: bigger UI for couch distance end return s end local function setFlag(obj, o, silent) if o.Flag then Blocks.Flags[o.Flag] = obj.Value end if o.Callback and not silent then task.spawn(o.Callback, obj.Value) end end local function register(obj, o) if o.Flag then Blocks._items[o.Flag] = obj Blocks.Flags[o.Flag] = obj.Value end return obj end ---------------------------------------------------------------------- -- Icons ---------------------------------------------------------------------- -- Built-in pixel icons. Anywhere an Icon is accepted you can pass one of these names -- or your own "rbxassetid://..." image. Blocks.IconAtlas = "rbxassetid://112530300441182" Blocks.Icons = { Home = { 0, 0 }, Settings = { 1, 0 }, Star = { 2, 0 }, Bell = { 3, 0 }, Discord = { 4, 0 }, Info = { 5, 0 }, User = { 6, 0 }, Heart = { 7, 0 }, Coin = { 0, 1 }, Gift = { 1, 1 }, Lock = { 2, 1 }, Check = { 3, 1 }, Warning = { 4, 1 }, Sword = { 5, 1 }, Shield = { 6, 1 }, Copy = { 7, 1 }, } local function setIcon(img, icon) local cell = Blocks.Icons[icon] if cell then img.Image = Blocks.IconAtlas img.ImageRectOffset = Vector2.new(cell[1] * 64, cell[2] * 64) img.ImageRectSize = Vector2.new(64, 64) img.ResampleMode = Enum.ResamplerMode.Pixelated else img.Image = icon or "" img.ImageRectOffset = Vector2.zero img.ImageRectSize = Vector2.zero img.ResampleMode = Enum.ResamplerMode.Default end end local function iconLabel(parent, icon, props) props.BackgroundTransparency = 1 props.Parent = parent local img = new("ImageLabel", props) setIcon(img, icon) return img end -- Smooth two-hue gradient for cards: warmer and lighter to cooler and darker. local function hueGradient(c) local h, sat, v = c:ToHSV() return ColorSequence.new( Color3.fromHSV((h + 0.06) % 1, math.clamp(sat * 0.85, 0, 1), math.clamp(v * 1.12, 0, 1)), Color3.fromHSV((h - 0.07) % 1, math.clamp(sat * 1.05, 0, 1), v * 0.7) ) end ---------------------------------------------------------------------- -- Theme / config ---------------------------------------------------------------------- function Blocks:SetTheme(theme) if type(theme) == "string" then theme = self.Themes[theme] elseif typeof(theme) == "Color3" then theme = { Accent = theme } end if not theme then return end self.Theme = theme for _, fn in ipairs(self._themed) do pcall(fn, theme) end end function Blocks:ExportConfig() local out = {} for flag, value in pairs(self.Flags) do if typeof(value) == "Color3" then out[flag] = { __color = value:ToHex() } elseif typeof(value) == "EnumItem" then out[flag] = { __key = value.Name } else out[flag] = value end end return HttpService:JSONEncode(out) end function Blocks:ImportConfig(json) local ok, data = pcall(HttpService.JSONDecode, HttpService, json) if not ok or type(data) ~= "table" then return false end for flag, value in pairs(data) do local item = self._items[flag] if item then if type(value) == "table" and value.__color then value = Color3.fromHex(value.__color) elseif type(value) == "table" and value.__key then value = Enum.KeyCode[value.__key] end pcall(item.Set, item, value) end end return true end ---------------------------------------------------------------------- -- Notifications ---------------------------------------------------------------------- local NOTIFY_COLORS = { Success = "Green", Warning = "Yellow", Error = "Red" } function Blocks:Notify(o) if type(o) == "string" then o = { Content = o } end local gui = getGui("BlocksUI_Notifications", 120) local list = gui:FindFirstChild("List") if not list then list = new("Frame", { Name = "List", BackgroundTransparency = 1, AnchorPoint = Vector2.new(1, 1), Position = UDim2.new(1, -16, 1, -16), Size = UDim2.fromOffset(270, 400), Parent = gui, }, { new("UIListLayout", { VerticalAlignment = Enum.VerticalAlignment.Bottom, Padding = UDim.new(0, 10), SortOrder = Enum.SortOrder.LayoutOrder, }), new("UIScale", { Scale = math.max(0.75, viewportScale()) }), }) end self._notifyCount = (self._notifyCount or 0) + 1 local wrap = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, LayoutOrder = self._notifyCount, Parent = list, }) local card = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Position = UDim2.fromScale(1.3, 0), Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, Parent = wrap, }, { corner(6), stroke(3), new("UIGradient", { Rotation = 90, Color = BODY }) }) local head = brick("Frame", { Size = UDim2.new(1, 0, 0, 26), Parent = card }, NOTIFY_COLORS[o.Type] or o.Color, 3) studs(head, 270, 26) text(head, { Text = o.Title or "Blocks UI", Position = UDim2.fromOffset(10, 0), Size = UDim2.new(1, -20, 1, 0), TextSize = 16, Stroke = 2.5, }) local body = text(card, { Text = o.Content or "", Position = UDim2.fromOffset(10, 32), Size = UDim2.new(1, -20, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, TextSize = 14, TextWrapped = true, TextTruncate = Enum.TextTruncate.None, TextYAlignment = Enum.TextYAlignment.Top, TextColor3 = rgb(232, 234, 244), Stroke = 1.5, }) new("UIPadding", { PaddingBottom = UDim.new(0, 12), Parent = body }) local duration = o.Duration or 4 tw(card, 0.35, { Position = UDim2.fromScale(0, 0) }, Enum.EasingStyle.Back) task.delay(duration, function() tw(card, 0.25, { Position = UDim2.fromScale(1.3, 0) }, Enum.EasingStyle.Quad, Enum.EasingDirection.In) task.wait(0.27) wrap:Destroy() end) end ---------------------------------------------------------------------- -- Intro ---------------------------------------------------------------------- local function measureText(str, size) local params = Instance.new("GetTextBoundsParams") params.Text = str params.Font = FONT params.Size = math.floor(size * TEXT_SCALE + 0.5) params.Width = 10000 local ok, bounds = pcall(TextService.GetTextBoundsAsync, TextService, params) return ok and bounds.X or #str * size * 0.7 end -- Logo lockup on a small panel: the panel pops in with the icon, widens as the title wipes -- out beside it, an accent line sweeps under the title, then it fades into the window. local function playIntro(gui, o, icon, title, subtitle) local hold = math.max(0, (o.Duration or 1.4) - 1.15) local hasIcon = icon ~= nil and icon ~= false and icon ~= "" local H, PAD = 84, 18 local GAP = hasIcon and 16 or 0 local ICON_W = hasIcon and H or 0 local titleW = measureText(title, 40) + 6 local subW = (subtitle and subtitle ~= "") and measureText(subtitle, 15) + 6 or 0 local fullW = math.max(titleW, subW) + 12 local startW = ICON_W + PAD * 2 local endW = ICON_W + GAP + fullW + PAD * 2 local group = new("CanvasGroup", { Name = "Intro", BackgroundTransparency = 1, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(endW + 60, H + PAD * 2 + 60), ZIndex = 50, Parent = gui, }) local groupScale = new("UIScale", { Scale = math.max(0.7, viewportScale()) * 1.2, Parent = group }) -- panel (Panel = false leaves the lockup floating with no background) local panel = new("Frame", { BackgroundColor3 = WHITE, BackgroundTransparency = o.Panel == false and 1 or 0, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(startW, H + PAD * 2), Parent = group, }, { new("UIGradient", { Rotation = 90, Color = BODY }) }) if o.Panel ~= false then stroke(4).Parent = panel local strip = brick("Frame", { Size = UDim2.new(1, 0, 0, 8), Parent = panel }, nil, 0) strip.BevelBottom.Visible = false end local pop = new("UIScale", { Scale = 0, Parent = panel }) tw(pop, 0.28, { Scale = 1 }, Enum.EasingStyle.Back) local row = new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(PAD, PAD + 3), Size = UDim2.new(1, -PAD * 2, 0, H), Parent = panel, }, { new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, GAP), SortOrder = Enum.SortOrder.LayoutOrder, }), }) if hasIcon then local img = iconLabel(row, icon, { Size = UDim2.fromOffset(H, H), Rotation = -30, LayoutOrder = 1 }) tw(img, 0.3, { Rotation = 0 }, Enum.EasingStyle.Back) end -- text column, hidden behind a clip that wipes open local clip = new("Frame", { BackgroundTransparency = 1, ClipsDescendants = true, Size = UDim2.fromOffset(0, H), LayoutOrder = 2, Parent = row, }) text(clip, { Text = title, Position = UDim2.fromOffset(5, 6), Size = UDim2.fromOffset(titleW, 42), TextSize = 40, Stroke = 4, TextTruncate = Enum.TextTruncate.None, }) local line = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Position = UDim2.fromOffset(5, 52), Size = UDim2.fromOffset(0, 6), Parent = clip, }, { stroke(2), new("UIGradient", { Rotation = 90, Color = hueSeq(Blocks.Theme.Accent) }) }) local sub if subW > 0 then sub = text(clip, { Text = subtitle, Position = UDim2.fromOffset(5, 64), Size = UDim2.fromOffset(subW, 18), TextSize = 15, TextColor3 = SUB, TextTransparency = 1, TextTruncate = Enum.TextTruncate.None, }) sub:FindFirstChildOfClass("UIStroke").Transparency = 1 end task.wait(hasIcon and 0.24 or 0.1) tw(panel, 0.3, { Size = UDim2.fromOffset(endW, H + PAD * 2) }, Enum.EasingStyle.Quart) tw(clip, 0.3, { Size = UDim2.fromOffset(fullW, H) }, Enum.EasingStyle.Quart) task.wait(0.18) tw(line, 0.32 + hold, { Size = UDim2.fromOffset(titleW - 4, 6) }, Enum.EasingStyle.Quad) if sub then tw(sub, 0.25, { TextTransparency = 0 }) tw(sub:FindFirstChildOfClass("UIStroke"), 0.25, { Transparency = 0 }) end task.wait(0.42 + hold) -- out: fade and grow while the window pops in underneath local k = groupScale.Scale tw(group, 0.2, { GroupTransparency = 1 }, Enum.EasingStyle.Quad, Enum.EasingDirection.In) tw(groupScale, 0.2, { Scale = k * 1.1 }, Enum.EasingStyle.Quad, Enum.EasingDirection.In) task.delay(0.22, function() group:Destroy() end) task.wait(0.08) end ---------------------------------------------------------------------- -- Window ---------------------------------------------------------------------- local Window = {} Window.__index = Window local Tab = {} Tab.__index = Tab function Blocks:CreateWindow(cfg) cfg = cfg or {} if cfg.Theme then self:SetTheme(cfg.Theme) end local W, H = cfg.Width or 620, cfg.Height or 410 local win = setmetatable({ Tabs = {}, Maid = {}, Visible = true, Minimized = false, Height = H, ContentW = W - SIDEBAR_W - 24, ToggleKey = cfg.ToggleKey or Enum.KeyCode.RightShift, GamepadToggleKey = (cfg.GamepadKey == nil) and Enum.KeyCode.ButtonSelect or cfg.GamepadKey, }, Window) self._windowCount = (self._windowCount or 0) + 1 local gui = new("ScreenGui", { Name = "BlocksUI_" .. self._windowCount, ResetOnSpawn = false, DisplayOrder = 100, ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = cfg.Parent or Players.LocalPlayer:WaitForChild("PlayerGui"), }) win.Gui = gui win.Id = self._windowCount win.SelectionImage = selectionImage() gui.DescendantAdded:Connect(function(d) if d:IsA("GuiButton") or d:IsA("TextBox") then d.SelectionImageObject = win.SelectionImage elseif d:IsA("ScrollingFrame") then d.Selectable = false -- the right stick scrolls pages instead end end) local s = viewportScale() local root = new("Frame", { Name = "Window", BackgroundTransparency = 1, AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0.5, -H * s / 2), Size = UDim2.fromOffset(W, H), Parent = gui, }) local scale = new("UIScale", { Scale = s * 0.7, Parent = root }) win.Root, win.Scale = root, scale trapSelection(root) new("Frame", { -- drop shadow block BackgroundColor3 = INK, BackgroundTransparency = 0.25, BorderSizePixel = 0, Position = UDim2.fromOffset(0, 8), Size = UDim2.fromScale(1, 1), Parent = root, }, { corner(8), stroke(4) }) local main = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Size = UDim2.fromScale(1, 1), ClipsDescendants = true, Parent = root, }, { corner(8), stroke(4) }) win.Main = main win.BodyGradient = new("UIGradient", { Rotation = 90, Color = BODY, Parent = main }) win.BackgroundImage = new("ImageLabel", { Name = "Background", BackgroundTransparency = 1, BorderSizePixel = 0, Size = UDim2.fromScale(1, 1), ScaleType = Enum.ScaleType.Crop, ZIndex = 0, Visible = false, Parent = main, }) -- Sidebar and pages (created before the header so the header draws on top) local sidebar = new("ScrollingFrame", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.fromOffset(0, HEADER_H), Size = UDim2.new(0, SIDEBAR_W, 1, -HEADER_H), CanvasSize = UDim2.new(), ScrollBarThickness = 0, ScrollingDirection = Enum.ScrollingDirection.Y, Parent = main, }, { new("UIListLayout", { Padding = UDim.new(0, 7), SortOrder = Enum.SortOrder.LayoutOrder }), new("UIPadding", { PaddingTop = UDim.new(0, 12), PaddingBottom = UDim.new(0, 10), PaddingLeft = UDim.new(0, 10), PaddingRight = UDim.new(0, 10), }), }) win.Sidebar = sidebar autoCanvas(sidebar, 22, 7) win.Pages = new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(SIDEBAR_W, HEADER_H), Size = UDim2.new(1, -SIDEBAR_W, 1, -HEADER_H), Parent = main, }) -- Header local header = brick("Frame", { Size = UDim2.new(1, 0, 0, HEADER_H), Active = true, Parent = main }) studs(header, W - HEADER_H * 2, HEADER_H, 22) local titleRow = new("Frame", { Name = "TitleRow", BackgroundTransparency = 1, Position = UDim2.fromOffset(8, 0), Size = UDim2.new(1, -HEADER_H * 2 - 14, 1, 0), Parent = header, }, { new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder, }), }) local icon = cfg.Icon if icon == nil then icon = Blocks.Icon end win.IconLabel = iconLabel(nil, icon or "", { Name = "Icon", Size = UDim2.fromOffset(36, 36), Visible = icon ~= nil and icon ~= false and icon ~= "", LayoutOrder = 1, }) win.IconLabel.Parent = titleRow local title = text(titleRow, { Text = cfg.Title or "Blocks UI", Size = UDim2.new(0, 0, 1, 0), AutomaticSize = Enum.AutomaticSize.X, TextSize = 24, Stroke = 3, TextTruncate = Enum.TextTruncate.None, LayoutOrder = 2, }) win.TitleLabel = title if cfg.SubTitle then text(titleRow, { Text = cfg.SubTitle, Size = UDim2.new(0, 0, 1, 0), AutomaticSize = Enum.AutomaticSize.X, TextSize = 14, Stroke = 2, TextTruncate = Enum.TextTruncate.None, LayoutOrder = 3, }) end local function headerButton(offset, color, glyph) local b = brick("TextButton", { Position = UDim2.new(1, -offset, 0, 0), Size = UDim2.fromOffset(HEADER_H, HEADER_H), Parent = header, }, color) text(b, { Text = glyph, Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 24, Stroke = 3, }) return b end local closeBtn = headerButton(HEADER_H, "Red", "X") local minBtn = headerButton(HEADER_H * 2, "Grey", "–") closeBtn.Activated:Connect(function() win:SetVisible(false) end) minBtn.Activated:Connect(function() win:SetMinimized(not win.Minimized) end) -- Dragging: the header moves the window (mouse and touch) draggable(win.Maid, header, root, function() win.Dragged = true end) -- Open button: shows while the window is hidden. By default only on touch devices -- (PC players use the toggle key). OpenButton = false hides it everywhere. local ob = cfg.OpenButton if ob == nil then ob = {} elseif ob == false then ob = { Enabled = false } end local isMobile = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled win.OpenButtonEnabled = ob.Enabled ~= false and (ob.MobileOnly == false or isMobile) local openIcon = ob.Icon if openIcon == nil then openIcon = icon end local reopen = new("ImageButton", { Name = "Open", BackgroundTransparency = 1, AutoButtonColor = false, AnchorPoint = Vector2.new(0, 0.5), Position = ob.Position or UDim2.new(0, 14, 0.5, 0), Size = UDim2.fromOffset(ob.Size or 56, ob.Size or 56), Visible = false, Parent = gui, }) setIcon(reopen, openIcon or "") if not openIcon or openIcon == "" then local face = brick("Frame", { Size = UDim2.fromScale(1, 1), Parent = reopen }) studs(face, 56, 56) text(face, { Text = string.sub(cfg.Title or "B", 1, 1), Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 30, Stroke = 3, }) end -- The open button can be dragged anywhere; a tap (no drag) opens the window. local openDrag = draggable(win.Maid, reopen, reopen) reopen.Activated:Connect(function() if not openDrag.Moved then win:SetVisible(true) end end) win.OpenButton = reopen if cfg.Background ~= nil then win:SetBackground(cfg.Background, cfg.BackgroundTransparency) end -- Toggle key + viewport scaling table.insert(win.Maid, UserInputService.InputBegan:Connect(function(input, processed) if not processed and not Blocks._listening and win.ToggleKey and input.KeyCode == win.ToggleKey then win:SetVisible(not win.Visible) end end)) local cam = workspace.CurrentCamera if cam then table.insert(win.Maid, cam:GetPropertyChangedSignal("ViewportSize"):Connect(function() local now = viewportScale() if win.Visible then scale.Scale = now end if not win.Dragged then root.Position = UDim2.new(0.5, 0, 0.5, -H * now / 2) end end)) end -- Intro (on by default). Intro = false skips it; Intro = { Duration, Title, SubTitle, Icon, Backdrop } tunes it. local intro = cfg.Intro if intro == nil or intro == true then intro = {} end if intro then root.Visible = false task.spawn(function() local introIcon = intro.Icon if introIcon == nil then introIcon = icon end local ok, err = pcall(playIntro, gui, intro, introIcon, intro.Title or cfg.Title or "Blocks UI", intro.SubTitle or cfg.SubTitle) if not ok then warn("[Blocks UI] intro failed: " .. tostring(err)) end if win.Visible and gui.Parent then root.Visible = true scale.Scale = viewportScale() * 0.7 tw(scale, 0.28, { Scale = viewportScale() }, Enum.EasingStyle.Back) if usingGamepad() then task.delay(0.3, function() win:Focus() end) end end end) else tw(scale, 0.28, { Scale = s }, Enum.EasingStyle.Back) if usingGamepad() then task.delay(0.3, function() win:Focus() end) end end win:_setupGamepad() table.insert(self._windows, win) return win end function Window:SetTitle(str) self.TitleLabel.Text = str end function Window:SetVisible(visible) if visible == self.Visible then return end self.Visible = visible local s = viewportScale() if visible then self.OpenButton.Visible = false self.Root.Visible = true self.Scale.Scale = s * 0.7 tw(self.Scale, 0.28, { Scale = s }, Enum.EasingStyle.Back) if usingGamepad() then task.delay(0.05, function() if self.Visible then self:Focus() end end) end else if self:_inWindow() then GuiService.SelectedObject = nil end tw(self.Scale, 0.15, { Scale = s * 0.7 }, Enum.EasingStyle.Quad, Enum.EasingDirection.In) task.delay(0.15, function() if not self.Visible then self.Root.Visible = false self.OpenButton.Visible = self.OpenButtonEnabled and not self._layoutMode end end) end end -- Show or hide the open button for good (true also shows it on PC). function Window:SetOpenButton(enabled) self.OpenButtonEnabled = enabled == true self.OpenButton.Visible = self.OpenButtonEnabled and not self.Visible end -- Change the title-bar icon and the open button icon. function Window:SetIcon(image) setIcon(self.IconLabel, image or "") self.IconLabel.Visible = image ~= nil and image ~= "" setIcon(self.OpenButton, image or "") end -- Background can be a Color3, a ColorSequence (top to bottom) or an image id string. -- transparency (0-1) fades the colour, or the image when an image is used. function Window:SetBackground(background, transparency) local image = self.BackgroundImage if type(background) == "string" then image.Image = background image.ImageTransparency = transparency or 0 image.Visible = true self.Sidebar.BackgroundTransparency = 0.35 return end image.Visible = false self.Sidebar.BackgroundTransparency = 0 if typeof(background) == "Color3" then local h, s, v = background:ToHSV() self.BodyGradient.Color = ColorSequence.new(background, Color3.fromHSV(h, s, v * 0.8)) elseif typeof(background) == "ColorSequence" then self.BodyGradient.Color = background else self.BodyGradient.Color = BODY end self.Main.BackgroundTransparency = transparency or 0 end function Window:_inWindow() local sel = GuiService.SelectedObject return sel ~= nil and sel:IsDescendantOf(self.Root) end function Window:_currentTab() for _, t in ipairs(self.Tabs) do if t.Selected then return t end end end -- Moves controller selection into the window: the given control, the open popup's button, -- or the first visible control on the current tab. function Window:Focus(target) if not target and self._modal then target = self._modal.Default end if not target then local tab = self:_currentTab() if tab then local top = tab.Page.AbsolutePosition.Y - 2 local best for _, d in ipairs(tab.Page:GetDescendants()) do if (d:IsA("GuiButton") or d:IsA("TextBox")) and d.Selectable and d.AbsolutePosition.Y >= top and shown(d, self.Gui) then local p, b = d.AbsolutePosition, best and best.AbsolutePosition if not b or p.Y < b.Y - 1 or (math.abs(p.Y - b.Y) <= 1 and p.X < b.X) then best = d end end end target = best or tab.Button end end if target then GuiService.SelectedObject = target end end function Window:_openModal(default, cancel) local prev = GuiService.SelectedObject self._modal = { Default = default, Cancel = cancel, Prev = prev } if usingGamepad() or (prev and prev:IsDescendantOf(self.Root)) then task.delay(0.05, function() if self._modal and self._modal.Default == default then GuiService.SelectedObject = default end end) end end function Window:_closeModal() local m = self._modal self._modal = nil if m and GuiService.SelectedObject ~= nil then if m.Prev and m.Prev:IsDescendantOf(self.Root) and shown(m.Prev, self.Gui) then GuiService.SelectedObject = m.Prev else task.defer(function() self:Focus() end) end end end -- Changes the key or controller button that shows and hides the window. -- Pass device = "Gamepad" to clear the controller button with nil. function Window:SetToggleKey(key, device) if device == "Gamepad" or isPadKey(key) then self.GamepadToggleKey = key ContextActionService:UnbindAction("BlocksUI_Toggle_" .. self.Id) if key and self._toggleAction then ContextActionService:BindActionAtPriority( "BlocksUI_Toggle_" .. self.Id, self._toggleAction, false, Enum.ContextActionPriority.High.Value, key ) end else self.ToggleKey = key end if self._refreshHints then self._refreshHints() end end function Window:_setupGamepad() local CAS_SINK, CAS_PASS = Enum.ContextActionResult.Sink, Enum.ContextActionResult.Pass -- View / Select (by default): show or hide; if the window is open but not selected, select it. self._toggleAction = function(_, state) if state ~= Enum.UserInputState.Begin or Blocks._listening then return CAS_PASS end if self.Visible and not self:_inWindow() then self:Focus() else self:SetVisible(not self.Visible) end return CAS_SINK end if self.GamepadToggleKey then self:SetToggleKey(self.GamepadToggleKey) end -- LB / RB switch tabs, B goes back (closes a popup, a dropdown, then the window). -- Only while the controller is in the window, so the game keeps these buttons otherwise. ContextActionService:BindActionAtPriority("BlocksUI_Nav_" .. self.Id, function(_, state, input) if state ~= Enum.UserInputState.Begin or Blocks._listening or not self.Visible or not self:_inWindow() then return CAS_PASS end local k = input.KeyCode if k == Enum.KeyCode.ButtonB then if self._modal then self._modal.Cancel() elseif self._closeDropdown then self._closeDropdown() else self:SetVisible(false) end elseif not self._modal and #self.Tabs > 1 then local i = table.find(self.Tabs, self:_currentTab()) or 1 i += (k == Enum.KeyCode.ButtonR1) and 1 or -1 if i < 1 then i = #self.Tabs elseif i > #self.Tabs then i = 1 end self:SelectTab(self.Tabs[i]) task.defer(function() self:Focus() end) end return CAS_SINK end, false, Enum.ContextActionPriority.High.Value, Enum.KeyCode.ButtonB, Enum.KeyCode.ButtonL1, Enum.KeyCode.ButtonR1) -- Right stick scrolls the open tab (lets you read pages with nothing to select). local stickY = 0 table.insert(self.Maid, UserInputService.InputChanged:Connect(function(input) if input.KeyCode == Enum.KeyCode.Thumbstick2 then stickY = math.abs(input.Position.Y) > 0.2 and input.Position.Y or 0 end end)) table.insert(self.Maid, RunService.RenderStepped:Connect(function(dt) if stickY ~= 0 and self.Visible and self:_inWindow() then local tab = self:_currentTab() if tab then local page = tab.Page page.CanvasPosition = Vector2.new(0, math.max(0, page.CanvasPosition.Y - stickY * 700 * dt)) end end end)) -- Button hints under the window, shown while a controller is being used. local hints = new("Frame", { Name = "ControllerHints", BackgroundColor3 = SLOT, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 1, 18), Size = UDim2.fromOffset(0, 36), AutomaticSize = Enum.AutomaticSize.X, Visible = false, Parent = self.Root, }, { stroke(3), new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, 7), SortOrder = Enum.SortOrder.LayoutOrder, }), new("UIPadding", { PaddingLeft = UDim.new(0, 10), PaddingRight = UDim.new(0, 12) }), }) self._refreshHints = function() for _, c in ipairs(hints:GetChildren()) do if c:IsA("GuiObject") then c:Destroy() end end local list = { { Enum.KeyCode.ButtonL1 }, { Enum.KeyCode.ButtonR1, "Tabs" }, { Enum.KeyCode.ButtonA, "Select" }, { Enum.KeyCode.ButtonB, "Back" }, { Enum.KeyCode.Thumbstick2, "Scroll" }, } if self.GamepadToggleKey then table.insert(list, { self.GamepadToggleKey, "Hide" }) end for i, item in ipairs(list) do glyph(hints, item[1], 24, { LayoutOrder = i * 2 - 1 }) if item[2] then text(hints, { Text = item[2], Size = UDim2.fromOffset(0, 24), AutomaticSize = Enum.AutomaticSize.X, TextSize = 13, TextTruncate = Enum.TextTruncate.None, LayoutOrder = i * 2, }) end end hints.Visible = usingGamepad() end self._refreshHints() table.insert(self.Maid, UserInputService.LastInputTypeChanged:Connect(function() hints.Visible = usingGamepad() end)) table.insert(self.Maid, UserInputService.GamepadConnected:Connect(self._refreshHints)) end ---------------------------------------------------------------------- -- On-screen buttons (touch) ---------------------------------------------------------------------- -- Every keybind gets an on-screen button for phones and tablets. Players can restyle it -- (shape, size, colour, their own label), pick how it fires (Tap, Hold, Toggle), and drag -- it anywhere and lock it. The style and position are saved in the keybind's Flag .. "Touch". -- Set Blocks.ShowTouchButtons = true to show them on PC too (handy for testing). local ACTION_SIZES = { Small = 52, Medium = 64, Large = 80 } local ACTION_COLORS = { Theme = false, Red = RED, Blue = rgb(52, 92, 204), Gold = YELLOW, Purple = rgb(152, 102, 222), Grey = GREY, } local ACTION_COLOR_ORDER = { "Theme", "Red", "Blue", "Gold", "Purple", "Grey" } local ACTION_SHAPES = { "Square", "Round", "Pill", "Diamond" } local ACTION_MODES = { "Tap", "Hold", "Toggle" } local OFF_CHIP = rgb(84, 84, 92) local function defaultTouchState(o) return { Shown = true, Shape = o.TouchShape or "Square", Size = o.TouchSize or "Medium", Color = o.TouchColor or "Theme", Mode = o.TouchMode or "Tap", Label = "", Locked = true, } end local function defaultTouchLabel(o) return o.TouchText or string.upper(string.sub(o.Name or "?", 1, 3)) end -- Draws an on-screen button into holder (used for the real button and the editor preview). local function drawAction(holder, st, o, on, editing) local old = holder:FindFirstChild("Visual") if old then old:Destroy() end local S = ACTION_SIZES[st.Size] or 64 local w, h = S, S if st.Shape == "Pill" then w, h = math.floor(S * 1.7), math.floor(S * 0.72) end holder.Size = UDim2.fromOffset(w, h) local vis = new("Frame", { Name = "Visual", BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), Parent = holder }) local color = ACTION_COLORS[st.Color] or Blocks.Theme.Accent if on then color = GREEN end local face = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Size = UDim2.fromScale(1, 1), Parent = vis, }, { new("UIGradient", { Rotation = 90, Color = hueSeq(color) }), stroke(on and 4 or 3, on and WHITE or INK), }) if st.Shape == "Diamond" then face.AnchorPoint = Vector2.new(0.5, 0.5) face.Position = UDim2.fromScale(0.5, 0.5) face.Size = UDim2.fromOffset(math.floor(S * 0.72), math.floor(S * 0.72)) face.Rotation = 45 elseif st.Shape == "Round" or st.Shape == "Pill" then new("UICorner", { CornerRadius = UDim.new(0.5, 0), Parent = face }) face:FindFirstChildOfClass("UIStroke").LineJoinMode = Enum.LineJoinMode.Round -- sharp joins would square off the circle else studs(face, w, h) new("Frame", { BackgroundColor3 = WHITE, BackgroundTransparency = 0.62, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, 2), Parent = face, }) new("Frame", { BackgroundColor3 = rgb(0, 0, 0), BackgroundTransparency = 0.68, BorderSizePixel = 0, AnchorPoint = Vector2.new(0, 1), Position = UDim2.fromScale(0, 1), Size = UDim2.new(1, 0, 0, 3), Parent = face, }) end if st.Label ~= "" or not o.TouchIcon then local label = text(vis, { Text = st.Label ~= "" and st.Label or defaultTouchLabel(o), Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextScaled = true, TextWrapped = false, TextTruncate = Enum.TextTruncate.None, Stroke = 2.5, }) new("UITextSizeConstraint", { MaxTextSize = math.floor(S * 0.3), MinTextSize = 6, Parent = label }) local pad = st.Shape == "Diamond" and 0.22 or 0.1 new("UIPadding", { PaddingLeft = UDim.new(pad, 0), PaddingRight = UDim.new(pad, 0), PaddingTop = UDim.new(pad, 0), PaddingBottom = UDim.new(pad, 0), Parent = label, }) else iconLabel(vis, o.TouchIcon, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(math.floor(S * 0.58), math.floor(S * 0.58)), }) end if editing then new("Frame", { Name = "EditRing", BackgroundTransparency = 1, Position = UDim2.fromOffset(-6, -6), Size = UDim2.new(1, 12, 1, 12), Parent = vis, }, { stroke(3, YELLOW) }) if not st.Shown then text(vis, { Text = "Hidden", AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 1, 8), Size = UDim2.fromOffset(80, 14), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 11, TextColor3 = YELLOW, Stroke = 1.5, }) end end end function Window:_addAction(o) self._actions = self._actions or {} local index = #self._actions + 1 local a = { Options = o, State = defaultTouchState(o), On = false, Editing = false } local btn = new("ImageButton", { Name = "Action_" .. tostring(o.Name or index), BackgroundTransparency = 1, AutoButtonColor = false, Selectable = false, Parent = self.Gui, }) a.Button = btn local press = new("UIScale", { Parent = btn }) local drag drag = draggable(self.Maid, btn, btn, nil, function(moved) if moved then a.SavePosition() end end) function a.Apply() local st = a.State drawAction(btn, st, o, a.On, a.Editing) if st.X and st.Y then btn.AnchorPoint = Vector2.new(0.5, 0.5) btn.Position = UDim2.fromScale(st.X, st.Y) else -- default spot: a column above the jump button btn.AnchorPoint = Vector2.new(1, 1) btn.Position = UDim2.new(1, -24, 1, -170 - (index - 1) * 86) end local deviceOk = UserInputService.TouchEnabled or Blocks.ShowTouchButtons btn.Visible = a.Editing or (st.Shown and deviceOk == true) drag.Enabled = a.Editing or not st.Locked end function a.Changed() if a.OnChange then a.OnChange(a.State) end end function a.SavePosition() local p, size, screen = btn.AbsolutePosition, btn.AbsoluteSize, self.Gui.AbsoluteSize a.State.X = math.clamp((p.X + size.X / 2) / math.max(1, screen.X), 0, 1) a.State.Y = math.clamp((p.Y + size.Y / 2) / math.max(1, screen.Y), 0, 1) a.Apply() a.Changed() end function a.Set(partial) for k, v in pairs(partial) do a.State[k] = v end if a.State.Mode ~= "Toggle" and a.State.Mode ~= "Hold" then a.On = false end a.Apply() a.Changed() end function a.Reset() a.State = defaultTouchState(o) a.On = false a.Apply() a.Changed() end local function fire(on) if on then if o.Callback then task.spawn(o.Callback, "Touch", true) end elseif o.Released then task.spawn(o.Released, "Touch", false) end end -- Hold: fires on press and again on release local holdInput btn.InputBegan:Connect(function(input) if not isPress(input) or a.Editing or Blocks._listening or a.State.Mode ~= "Hold" then return end holdInput = input a.On = true a.Apply() fire(true) end) table.insert(self.Maid, UserInputService.InputEnded:Connect(function(input) if holdInput and (input == holdInput or (holdInput.UserInputType == Enum.UserInputType.MouseButton1 and input.UserInputType == Enum.UserInputType.MouseButton1)) then holdInput = nil a.On = false a.Apply() fire(false) end end)) -- Tap and Toggle: fire on release, unless the button was being dragged btn.Activated:Connect(function() local mode = a.State.Mode if drag.Moved or a.Editing or Blocks._listening or mode == "Hold" then return end press.Scale = 0.85 tw(press, 0.18, { Scale = 1 }, Enum.EasingStyle.Back) if mode == "Toggle" then a.On = not a.On a.Apply() fire(a.On) else fire(true) fire(false) end end) table.insert(self._actions, a) themed(function() if btn.Parent then a.Apply() end end) return a end -- Opens the editor for one on-screen button: shape, size, colour, label, mode, show and lock. function Window:EditTouchButton(a) if not a then return end if self._editorClose then self._editorClose() end if not self.Visible then self:SetVisible(true) end local o = a.Options local overlay = new("TextButton", { AutoButtonColor = false, Selectable = false, Text = "", BackgroundColor3 = INK, BackgroundTransparency = 1, BorderSizePixel = 0, Position = UDim2.fromOffset(0, HEADER_H), Size = UDim2.new(1, 0, 1, -HEADER_H), ZIndex = 40, Parent = self.Main, }) tw(overlay, 0.15, { BackgroundTransparency = 0.4 }) local W = math.min(450, self.Root.Size.X.Offset - 30) local CH = math.min(340, self.Height - HEADER_H - 14) local PREVIEW_W = 118 local colW = W - PREVIEW_W - 24 local card = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(W, CH), Parent = overlay, }, { stroke(3), new("UIGradient", { Rotation = 90, Color = BODY }) }) trapSelection(card) local pop = new("UIScale", { Scale = 0.7, Parent = card }) tw(pop, 0.25, { Scale = 1 }, Enum.EasingStyle.Back) local head = brick("Frame", { Size = UDim2.new(1, 0, 0, 38), Parent = card }) studs(head, W, 38) iconLabel(head, "Settings", { Position = UDim2.new(0, 8, 0.5, -13), Size = UDim2.fromOffset(26, 26) }) text(head, { Text = "Button: " .. tostring(o.Name or ""), Position = UDim2.fromOffset(42, 0), Size = UDim2.new(1, -50, 1, 0), TextSize = 17, Stroke = 2.5, }) local body = new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(0, 38), Size = UDim2.new(1, -PREVIEW_W, 1, -38 - 52), Parent = card, }, { new("UIListLayout", { Padding = UDim.new(0, 7), SortOrder = Enum.SortOrder.LayoutOrder }), new("UIPadding", { PaddingTop = UDim.new(0, 10), PaddingLeft = UDim.new(0, 12), PaddingRight = UDim.new(0, 12), }), }) -- live preview local previewBox = new("Frame", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.new(1, -PREVIEW_W + 2, 0, 48), Size = UDim2.fromOffset(PREVIEW_W - 14, PREVIEW_W - 14), ClipsDescendants = true, Parent = card, }, { stroke(2.5) }) local preview = new("Frame", { BackgroundTransparency = 1, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Parent = previewBox, }) local previewScale = new("UIScale", { Parent = preview }) text(card, { Text = "Preview", Position = UDim2.new(1, -PREVIEW_W + 2, 0, 48 + PREVIEW_W - 8), Size = UDim2.fromOffset(PREVIEW_W - 14, 16), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 11, TextColor3 = SUB, Stroke = 1.5, }) local refreshers = {} local function refresh() for _, fn in ipairs(refreshers) do fn() end drawAction(preview, a.State, o, false, false) local size = preview.Size previewScale.Scale = math.min(1, (PREVIEW_W - 32) / math.max(size.X.Offset, size.Y.Offset)) end local order = 0 local function rowFrame(name) order += 1 local r = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 28), LayoutOrder = order, Parent = body, }) text(r, { Text = string.upper(name), Size = UDim2.new(0, 64, 1, 0), TextSize = 12, TextColor3 = SUB, Stroke = 1.5, }) return new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(66, 0), Size = UDim2.new(1, -66, 1, 0), Parent = r, }, { new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, 4), SortOrder = Enum.SortOrder.LayoutOrder, }), }) end -- one font size per row that fits the longest label, so chips in a row match local function fitSize(labels, width) local longest = 0 local pick = "" for _, l in ipairs(labels) do if #l > longest then longest, pick = #l, l end end for size = 12, 6, -1 do if measureText(string.upper(pick), size) <= width - 8 then return size end end return 6 end local function chip(parent, width, label, layoutOrder, textSize) local b = new("TextButton", { AutoButtonColor = false, Text = "", BackgroundColor3 = WHITE, BorderSizePixel = 0, Size = UDim2.fromOffset(width, 28), LayoutOrder = layoutOrder, Parent = parent, }, { stroke(2.5) }) local g = new("UIGradient", { Rotation = 90, Parent = b }) local l if label then l = text(b, { Text = label, Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = textSize or 10, TextTruncate = Enum.TextTruncate.None, Stroke = 1.5, }) end return b, g, l end local function chips(name, options, key) local list = rowFrame(name) local n = #options local cw = math.floor((colW - 66 - 4 * (n - 1)) / n) local grads = {} local ts = fitSize(options, cw) for i, opt in ipairs(options) do local b, g = chip(list, cw, opt, i, ts) grads[opt] = g b.Activated:Connect(function() a.Set({ [key] = opt }) refresh() end) end table.insert(refreshers, function() for opt, g in pairs(grads) do g.Color = hueSeq(a.State[key] == opt and Blocks.Theme.Accent or OFF_CHIP) end end) end -- label do local list = rowFrame("Label") local box = new("TextBox", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, 28), FontFace = FONT, TextSize = 12, TextColor3 = WHITE, PlaceholderText = defaultTouchLabel(o) .. " (type a name)", PlaceholderColor3 = GREY, Text = a.State.Label, ClearTextOnFocus = false, ClipsDescendants = true, TextXAlignment = Enum.TextXAlignment.Left, Parent = list, }, { stroke(2.5), new("UIPadding", { PaddingLeft = UDim.new(0, 6), PaddingRight = UDim.new(0, 6) }) }) box:GetPropertyChangedSignal("Text"):Connect(function() if utf8.len(box.Text) and utf8.len(box.Text) > 10 then box.Text = string.sub(box.Text, 1, utf8.offset(box.Text, 11) - 1) end end) box.FocusLost:Connect(function() a.Set({ Label = box.Text }) refresh() end) table.insert(refreshers, function() if not box:IsFocused() then box.Text = a.State.Label end end) end chips("Shape", ACTION_SHAPES, "Shape") chips("Size", { "Small", "Medium", "Large" }, "Size") -- colour do local list = rowFrame("Colour") local n = #ACTION_COLOR_ORDER local cw = math.min(34, math.floor((colW - 66 - 4 * (n - 1)) / n)) for i, name in ipairs(ACTION_COLOR_ORDER) do local b, g = chip(list, cw, nil, i) local mark = iconLabel(b, "Check", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(18, 18), }) b.Activated:Connect(function() a.Set({ Color = name }) refresh() end) table.insert(refreshers, function() g.Color = hueSeq(ACTION_COLORS[name] or Blocks.Theme.Accent) mark.Visible = a.State.Color == name end) end end chips("Mode", ACTION_MODES, "Mode") -- shown / locked do local list = rowFrame("Options") local half = math.floor((colW - 66 - 4) / 2) local ts = fitSize({ "Hidden", "Locked" }, half) local sb, sg, sl = chip(list, half, "", 1, ts) local lb, lg, ll = chip(list, half, "", 2, ts) sb.Activated:Connect(function() a.Set({ Shown = not a.State.Shown }) refresh() end) lb.Activated:Connect(function() a.Set({ Locked = not a.State.Locked }) refresh() end) table.insert(refreshers, function() sl.Text = a.State.Shown and "Shown" or "Hidden" sg.Color = hueSeq(a.State.Shown and GREEN or OFF_CHIP) ll.Text = a.State.Locked and "Locked" or "Free" lg.Color = hueSeq(a.State.Locked and GREEN or YELLOW) end) end -- footer local close local footer = new("Frame", { BackgroundTransparency = 1, Position = UDim2.new(0, 12, 1, -44), Size = UDim2.new(1, -24, 0, 34), Parent = card, }, { new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder, }), }) local bw = math.floor((W - 24 - 16) / 3) local function footButton(label, color, layoutOrder, fn) local b = brick("TextButton", { Size = UDim2.fromOffset(bw, 34), LayoutOrder = layoutOrder, Parent = footer }, color) text(b, { Text = label, Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 15, Stroke = 2, }) pressable(b) b.Activated:Connect(fn) return b end footButton("Move", "Yellow", 1, function() close() self:EditLayout(a) end) footButton("Reset", "Grey", 2, function() a.Reset() refresh() end) local done = footButton("Done", "Green", 3, function() close() end) close = function() if self._editorClose == close then self._editorClose = nil end self:_closeModal() overlay:Destroy() end self._editorClose = close self:_openModal(done, close) refresh() end -- Move mode: the window hides, on-screen buttons get a yellow outline and can be dragged -- anywhere. Done locks them where they are. Pass one button to move only that one. function Window:EditLayout(only) if self._layoutMode then return end local list = only and { only } or (self._actions or {}) if #list == 0 then Blocks:Notify({ Title = "No buttons", Content = "There are no on-screen buttons to move.", Type = "Warning" }) return end local wasVisible = self.Visible self._layoutMode = true self:SetVisible(false) self.OpenButton.Visible = false for _, a in ipairs(list) do a.Editing = true a.Apply() end local bar = new("Frame", { Name = "LayoutBar", BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 12), Size = UDim2.fromOffset(340, 50), Parent = self.Gui, }, { stroke(3), new("UIGradient", { Rotation = 90, Color = BODY }) }) new("UIScale", { Scale = math.max(0.8, viewportScale()), Parent = bar }) iconLabel(bar, "Lock", { Position = UDim2.new(0, 10, 0.5, -14), Size = UDim2.fromOffset(28, 28) }) text(bar, { Text = "Drag to move", Position = UDim2.fromOffset(46, 0), Size = UDim2.new(1, -150, 1, 0), TextSize = 15, }) local done = brick("TextButton", { AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -9, 0.5, 0), Size = UDim2.fromOffset(94, 34), Parent = bar, }, "Green") text(done, { Text = "Lock", Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 15, Stroke = 2, }) pressable(done) done.Activated:Connect(function() for _, a in ipairs(list) do a.Editing = false a.State.Locked = true a.Apply() a.Changed() end bar:Destroy() self._layoutMode = nil if wasVisible then self:SetVisible(true) else self.OpenButton.Visible = self.OpenButtonEnabled end end) if usingGamepad() then GuiService.SelectedObject = done end end function Window:Toggle() self:SetVisible(not self.Visible) end function Window:SetMinimized(minimized) self.Minimized = minimized self.Sidebar.Visible = not minimized self.Pages.Visible = not minimized if minimized and self:_inWindow() and not shown(GuiService.SelectedObject, self.Gui) then self:Focus() end tw(self.Root, 0.22, { Size = UDim2.fromOffset(self.Root.Size.X.Offset, minimized and HEADER_H or self.Height), }) end function Window:SelectTab(tab) for _, t in ipairs(self.Tabs) do t.Selected = (t == tab) t.Page.Visible = t.Selected t._refresh() end end function Window:Destroy() ContextActionService:UnbindAction("BlocksUI_Toggle_" .. self.Id) ContextActionService:UnbindAction("BlocksUI_Nav_" .. self.Id) if self:_inWindow() then GuiService.SelectedObject = nil end for _, c in ipairs(self.Maid) do c:Disconnect() end self.Gui:Destroy() local i = table.find(Blocks._windows, self) if i then table.remove(Blocks._windows, i) end end -- Modal dialog: Window:Dialog({ Title, Content, Buttons = { { Name, Color, Callback } } }) function Window:Dialog(o) local overlay = new("TextButton", { AutoButtonColor = false, Selectable = false, Text = "", BackgroundColor3 = INK, BackgroundTransparency = 1, BorderSizePixel = 0, Position = UDim2.fromOffset(0, HEADER_H), Size = UDim2.new(1, 0, 1, -HEADER_H), ZIndex = 20, Parent = self.Main, }) tw(overlay, 0.15, { BackgroundTransparency = 0.4 }) local card = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(330, 0), AutomaticSize = Enum.AutomaticSize.Y, ZIndex = 21, Parent = overlay, }, { corner(6), stroke(3), new("UIGradient", { Rotation = 90, Color = BODY }) }) local pop = new("UIScale", { Scale = 0.7, Parent = card }) trapSelection(card) tw(pop, 0.25, { Scale = 1 }, Enum.EasingStyle.Back) local head = brick("Frame", { Size = UDim2.new(1, 0, 0, 34), ZIndex = 21, Parent = card }) studs(head, 330, 34) text(head, { Text = o.Title or "Are you sure?", Position = UDim2.fromOffset(12, 0), Size = UDim2.new(1, -24, 1, 0), TextSize = 19, Stroke = 2.5, ZIndex = 22, }) local content = new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(0, 34), Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, ZIndex = 21, Parent = card, }, { new("UIListLayout", { Padding = UDim.new(0, 12), SortOrder = Enum.SortOrder.LayoutOrder }), new("UIPadding", { PaddingTop = UDim.new(0, 12), PaddingBottom = UDim.new(0, 16), PaddingLeft = UDim.new(0, 14), PaddingRight = UDim.new(0, 14), }), }) text(content, { Text = o.Content or "", Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, TextSize = 15, TextWrapped = true, TextTruncate = Enum.TextTruncate.None, Stroke = 1.5, ZIndex = 22, LayoutOrder = 1, }) local buttons = o.Buttons or { { Name = "OK" } } local rowF = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 38), ZIndex = 21, LayoutOrder = 2, Parent = content, }) local gap = 10 local bw = (330 - 28 - gap * (#buttons - 1)) / #buttons local faces, presses = {}, {} for i, b in ipairs(buttons) do new("Frame", { BackgroundColor3 = INK, BorderSizePixel = 0, Position = UDim2.fromOffset((i - 1) * (bw + gap), 4), Size = UDim2.fromOffset(bw, 34), ZIndex = 21, Parent = rowF, }, { corner(6) }) local face = brick("TextButton", { Position = UDim2.fromOffset((i - 1) * (bw + gap), 0), Size = UDim2.fromOffset(bw, 34), ZIndex = 22, Parent = rowF, }, b.Color or (i == 1 and "Green" or "Grey")) text(face, { Text = b.Name or "OK", Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 17, Stroke = 2.5, ZIndex = 23, }) pressable(face) local function press() self:_closeModal() overlay:Destroy() if b.Callback then task.spawn(b.Callback) end end faces[i], presses[i] = face, press face.Activated:Connect(press) end self:_openModal(faces[1], presses[#presses]) end ---------------------------------------------------------------------- -- Tabs ---------------------------------------------------------------------- function Window:AddTab(o) if type(o) == "string" then o = { Name = o } end local tab = setmetatable({ Window = self, Width = self.ContentW, Order = 0, Selected = false }, Tab) local btn = new("TextButton", { AutoButtonColor = false, Text = "", BackgroundColor3 = WHITE, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, 34), LayoutOrder = #self.Tabs + 1, Parent = self.Sidebar, }, { corner(6), stroke(3) }) local grad = new("UIGradient", { Rotation = 90, Parent = btn }) local studLayer = studs(btn, SIDEBAR_W - 20, 34) local pad = 10 if o.Icon then iconLabel(btn, o.Icon, { Position = UDim2.new(0, 7, 0.5, -11), Size = UDim2.fromOffset(22, 22) }) pad = 36 end local label = text(btn, { Text = o.Name or "Tab", Position = UDim2.fromOffset(pad, 0), Size = UDim2.new(1, -pad - 6, 1, 0), TextSize = 16, }) local badge = brick("Frame", { AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -5, 0.5, 0), Size = UDim2.fromOffset(38, 18), Visible = false, Parent = btn, }, "Red", 2) local badgeText = text(badge, { Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 11, Stroke = 1.5, }) -- tab:SetBadge("NEW") shows a small red tag on the tab; tab:SetBadge(nil) removes it. function tab:SetBadge(str) badge.Visible = str ~= nil and str ~= "" badgeText.Text = str or "" label.Size = UDim2.new(1, -pad - (badge.Visible and 48 or 6), 1, 0) end tab:SetBadge(o.Badge) tab.Page = new("ScrollingFrame", { BackgroundTransparency = 1, BorderSizePixel = 0, Size = UDim2.fromScale(1, 1), CanvasSize = UDim2.new(), ScrollBarThickness = 4, ScrollBarImageColor3 = GREY, ScrollingDirection = Enum.ScrollingDirection.Y, Visible = false, Parent = self.Pages, }, { new("UIListLayout", { Padding = UDim.new(0, 9), SortOrder = Enum.SortOrder.LayoutOrder }), new("UIPadding", { PaddingTop = UDim.new(0, 12), PaddingBottom = UDim.new(0, 12), PaddingLeft = UDim.new(0, 12), PaddingRight = UDim.new(0, 12), }), }) autoCanvas(tab.Page, 24, 9) tab._refresh = function() if tab.Selected then grad.Color = hueSeq(Blocks.Theme.Accent) label.TextColor3 = WHITE studLayer.Visible = true else grad.Color = ColorSequence.new(rgb(60, 60, 72), rgb(44, 44, 54)) label.TextColor3 = SUB studLayer.Visible = false end end themed(tab._refresh) tab.Button = btn btn.Activated:Connect(function() self:SelectTab(tab) end) table.insert(self.Tabs, tab) if #self.Tabs == 1 then self:SelectTab(tab) end return tab end function Tab:_next() self.Order += 1 return self.Order end function Tab:_row(h) return new("Frame", { BackgroundColor3 = ROW, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, h), LayoutOrder = self:_next(), Parent = self.Page, }, { corner(6), stroke(2) }) end local function rowTitle(row, str, rightInset) return text(row, { Text = str or "", Position = UDim2.fromOffset(12, 0), Size = UDim2.new(1, -(rightInset or 12) - 12, 0, 40), TextSize = 16, }) end function Tab:AddSection(name, icon) local row = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 24), LayoutOrder = self:_next(), Parent = self.Page, }) local x = 0 if icon then iconLabel(row, icon, { Position = UDim2.new(0, 0, 0.5, -11), Size = UDim2.fromOffset(22, 22) }) x = 28 end local label = text(row, { Text = string.upper(name or "Section"), Position = UDim2.fromOffset(x, 0), Size = UDim2.new(1, -x, 1, 0), TextSize = 15, }) themed(function(t) label.TextColor3 = hueSeq(t.Accent).Keypoints[1].Value end) return label end function Tab:AddLabel(str) local row = self:_row(34) local label = rowTitle(row, str) label.Size = UDim2.new(1, -24, 1, 0) return { Frame = row, Set = function(_, v) label.Text = v end, } end function Tab:AddParagraph(o) local row = self:_row(0) row.AutomaticSize = Enum.AutomaticSize.Y new("UIListLayout", { Padding = UDim.new(0, 4), SortOrder = Enum.SortOrder.LayoutOrder, Parent = row }) new("UIPadding", { PaddingTop = UDim.new(0, 10), PaddingBottom = UDim.new(0, 12), PaddingLeft = UDim.new(0, 12), PaddingRight = UDim.new(0, 12), Parent = row, }) local title = text(row, { Text = o.Title or "", Size = UDim2.new(1, 0, 0, 20), TextSize = 17, LayoutOrder = 1 }) local content = text(row, { Text = o.Content or "", Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, TextSize = 14, TextColor3 = SUB, TextWrapped = true, TextTruncate = Enum.TextTruncate.None, TextYAlignment = Enum.TextYAlignment.Top, Stroke = 1.5, LayoutOrder = 2, }) return { Frame = row, Set = function(_, t, c) title.Text = t or title.Text content.Text = c or content.Text end, } end function Tab:AddButton(o) local holder = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 42), LayoutOrder = self:_next(), Parent = self.Page, }) new("Frame", { BackgroundColor3 = INK, BorderSizePixel = 0, Position = UDim2.fromOffset(0, 5), Size = UDim2.new(1, 0, 0, 37), Parent = holder, }, { corner(6), stroke(3) }) local face = brick("TextButton", { Size = UDim2.new(1, 0, 0, 37), Parent = holder }, o.Color) studs(face, self.Width, 37) local label = text(face, { Text = o.Name or "Button", Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 18, Stroke = 2.5, }) pressable(face) face.Activated:Connect(function() if o.Callback then task.spawn(o.Callback) end end) return { Frame = holder, SetText = function(_, v) label.Text = v end, } end function Tab:AddToggle(o) local row = self:_row(40) rowTitle(row, o.Name, 70) local track = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0), Size = UDim2.fromOffset(48, 24), Parent = row, }, { corner(6), stroke(2.5) }) local grad = new("UIGradient", { Rotation = 90, Parent = track }) local knob = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Position = UDim2.fromOffset(3, 3), Size = UDim2.fromOffset(18, 18), Parent = track, }, { corner(4), stroke(2), new("UIGradient", { Rotation = 90, Color = ColorSequence.new(WHITE, rgb(196, 200, 216)) }), }) local hit = new("TextButton", { BackgroundTransparency = 1, Text = "", Size = UDim2.fromScale(1, 1), Parent = row, }) local obj = { Frame = row, Value = o.Default == true, Type = "Toggle" } local function render(instant) grad.Color = obj.Value and hueSeq(GREEN) or ColorSequence.new(SLOT, SLOT) local pos = UDim2.fromOffset(obj.Value and 27 or 3, 3) if instant then knob.Position = pos else tw(knob, 0.14, { Position = pos }, Enum.EasingStyle.Back) end end function obj:Set(v, silent) self.Value = v == true render() setFlag(self, o, silent) end hit.Activated:Connect(function() obj:Set(not obj.Value) end) render(true) return register(obj, o) end function Tab:AddSlider(o) local min, max, step = o.Min or 0, o.Max or 100, o.Step or 1 local decimals = step < 1 and math.clamp(math.ceil(-math.log10(step)), 1, 4) or 0 local row = self:_row(58) rowTitle(row, o.Name, 90).Size = UDim2.new(1, -110, 0, 34) local valueLabel = text(row, { Position = UDim2.new(1, -102, 0, 0), Size = UDim2.fromOffset(90, 34), TextXAlignment = Enum.TextXAlignment.Right, TextSize = 16, }) themed(function(t) valueLabel.TextColor3 = hueSeq(t.Accent).Keypoints[1].Value end) local track = new("TextButton", { AutoButtonColor = false, Text = "", BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.fromOffset(13, 36), Size = UDim2.new(1, -26, 0, 12), Parent = row, }, { corner(5), stroke(2.5) }) local fill = brick("Frame", { Size = UDim2.fromScale(0, 1), Parent = track }, nil, 0) local knob = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0, 0.5), Size = UDim2.fromOffset(14, 22), Parent = track, }, { corner(4), stroke(2.5), new("UIGradient", { Rotation = 90, Color = ColorSequence.new(WHITE, rgb(196, 200, 216)) }), }) local obj = { Frame = row, Type = "Slider" } local function render() local a = (max > min) and (obj.Value - min) / (max - min) or 0 fill.Size = UDim2.fromScale(a, 1) knob.Position = UDim2.fromScale(a, 0.5) valueLabel.Text = string.format("%." .. decimals .. "f", obj.Value) .. (o.Suffix or "") end local function snap(v) v = min + math.floor((v - min) / step + 0.5) * step return math.clamp(v, min, max) end function obj:Set(v, silent) v = snap(tonumber(v) or min) local changed = v ~= self.Value self.Value = v render() if changed then setFlag(self, o, silent) end end obj.Value = snap(o.Default or min) render() onDrag(self.Window.Maid, track, function(x) obj:Set(min + (max - min) * x) end) gamepadAdjust(track, true, false, function(dx) obj:Set(obj.Value + dx * math.max(step, (max - min) / 50)) end) return register(obj, o) end function Tab:AddDropdown(o) local options = o.Options or {} local multi = o.Multi == true local row = self:_row(40) row.ClipsDescendants = true rowTitle(row, o.Name, 190).Size = UDim2.new(1, -210, 0, 40) local box = new("TextButton", { AutoButtonColor = false, Text = "", BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.new(1, -190, 0, 7), Size = UDim2.fromOffset(178, 26), Parent = row, }, { corner(5), stroke(2.5) }) local current = text(box, { Position = UDim2.fromOffset(8, 0), Size = UDim2.new(1, -32, 1, 0), TextSize = 14, Stroke = 1.5, }) local arrow = text(box, { Text = "▼", Position = UDim2.new(1, -24, 0, 0), Size = UDim2.fromOffset(20, 26), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 12, Stroke = 1.5, }) local list = new("ScrollingFrame", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.fromOffset(12, 44), Size = UDim2.new(1, -24, 0, 0), Visible = false, CanvasSize = UDim2.new(), ScrollBarThickness = 4, ScrollBarImageColor3 = GREY, ScrollingDirection = Enum.ScrollingDirection.Y, Parent = row, }, { corner(5), stroke(2.5), new("UIListLayout", { Padding = UDim.new(0, 3), SortOrder = Enum.SortOrder.LayoutOrder }), new("UIPadding", { PaddingTop = UDim.new(0, 4), PaddingBottom = UDim.new(0, 4), PaddingLeft = UDim.new(0, 4), PaddingRight = UDim.new(0, 8), }), }) autoCanvas(list, 8, 3) local obj = { Frame = row, Type = "Dropdown", Open = false } local function isSelected(opt) if multi then return table.find(obj.Value, opt) ~= nil end return obj.Value == opt end local function listHeight() return math.min(#options, 5) * 29 + 8 end local function render() if multi then current.Text = #obj.Value > 0 and table.concat(obj.Value, ", ") or "None" else current.Text = obj.Value ~= nil and tostring(obj.Value) or "Select..." end for _, child in ipairs(list:GetChildren()) do if child:IsA("TextButton") then local on = isSelected(child.Name) child.BackgroundTransparency = on and 0 or 1 child.BevelTop.Visible = on child.BevelBottom.Visible = on child.Label.TextColor3 = on and WHITE or SUB end end end local win = self.Window local closer local function setOpen(open) obj.Open = open local h = listHeight() list.Size = UDim2.new(1, -24, 0, h) list.Visible = open arrow.Text = open and "▲" or "▼" tw(row, 0.18, { Size = UDim2.new(1, 0, 0, open and 40 + h + 14 or 40) }) if open then win._closeDropdown = closer if win:_inWindow() then local current = multi and obj.Value[1] or obj.Value local pick = current ~= nil and list:FindFirstChild(tostring(current)) if not pick then for _, c in ipairs(list:GetChildren()) do if c:IsA("TextButton") and c.LayoutOrder == 1 then pick = c end end end task.defer(function() GuiService.SelectedObject = pick or box end) end else if win._closeDropdown == closer then win._closeDropdown = nil end if win:_inWindow() then GuiService.SelectedObject = box end end end closer = function() setOpen(false) end local function build() for _, child in ipairs(list:GetChildren()) do if child:IsA("TextButton") then child:Destroy() end end for i, opt in ipairs(options) do opt = tostring(opt) local item = brick("TextButton", { Name = opt, Size = UDim2.new(1, 0, 0, 26), LayoutOrder = i, Parent = list, }, nil, 0) text(item, { Name = "Label", Text = opt, Position = UDim2.fromOffset(8, 0), Size = UDim2.new(1, -16, 1, 0), TextSize = 14, Stroke = 1.5, }) item.Activated:Connect(function() if multi then local idx = table.find(obj.Value, opt) if idx then table.remove(obj.Value, idx) else table.insert(obj.Value, opt) end render() setFlag(obj, o) else obj.Value = opt render() setFlag(obj, o) setOpen(false) end end) end render() end function obj:Set(v, silent) if multi then self.Value = type(v) == "table" and table.clone(v) or {} else self.Value = v end render() setFlag(self, o, silent) end function obj:SetOptions(newOptions) options = newOptions build() if self.Open then setOpen(true) end end if multi then obj.Value = type(o.Default) == "table" and table.clone(o.Default) or {} else obj.Value = o.Default end build() box.Activated:Connect(function() setOpen(not obj.Open) end) return register(obj, o) end function Tab:AddInput(o) local row = self:_row(40) rowTitle(row, o.Name, 190).Size = UDim2.new(1, -210, 0, 40) local box = new("TextBox", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.new(1, -190, 0, 7), Size = UDim2.fromOffset(178, 26), FontFace = FONT, TextSize = 12, TextColor3 = WHITE, PlaceholderText = o.Placeholder or "Type here...", PlaceholderColor3 = GREY, Text = o.Default and tostring(o.Default) or "", ClearTextOnFocus = false, ClipsDescendants = true, Parent = row, }, { corner(5), stroke(2.5), new("UIPadding", { PaddingLeft = UDim.new(0, 8), PaddingRight = UDim.new(0, 8) }) }) local outline = box:FindFirstChildOfClass("UIStroke") box.Focused:Connect(function() outline.Color = Blocks.Theme.Accent end) local obj = { Frame = row, Type = "Input", Value = box.Text } function obj:Set(v, silent) v = tostring(v or "") if o.Numeric then v = tostring(tonumber(v) or "") end self.Value = v box.Text = v setFlag(self, o, silent) end box.FocusLost:Connect(function() outline.Color = INK obj:Set(box.Text) end) return register(obj, o) end -- Keybind: one action, bindable on every device. -- Keyboard: a key (Default). Controller / console: a button (GamepadDefault). -- Touch: an on-screen button the player can restyle, move and lock (TouchButton = false turns it off). -- { Name, Default, GamepadDefault, Flag, Callback(key), Released(key), Changed(key, device), -- TouchButton, TouchIcon, TouchText, TouchShape, TouchSize, TouchColor, TouchMode } -- On-screen buttons call Callback("Touch", true) and Released("Touch", false). In Toggle mode -- the first tap calls Callback and the next calls Released; in Hold mode press and release do. -- To rebind, select a box and press any key or controller button: keys go to the keyboard -- slot, buttons to the controller slot. Esc cancels, Backspace clears the key, and the -- controller's View / Select button clears the controller button. function Tab:AddKeybind(o) local win = self.Window local row = self:_row(40) local title = rowTitle(row, o.Name, 230) local slots = new("Frame", { BackgroundTransparency = 1, AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 7), Size = UDim2.fromOffset(0, 26), AutomaticSize = Enum.AutomaticSize.X, Parent = row, }, { new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, HorizontalAlignment = Enum.HorizontalAlignment.Right, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder, }), }) local function slot(order, width, color) local b = brick("TextButton", { Size = UDim2.fromOffset(width, 26), LayoutOrder = order, Parent = slots }, color or "Grey", 2.5) local content = new("Frame", { BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), Parent = b }) return b, content end local keyBtn, keyContent = slot(1, 92) local padBtn, padContent = slot(2, 64) local touchBtn, touchContent = slot(3, 84) local obj = { Frame = row, Type = "Keybind", Value = o.Default, Gamepad = o.GamepadDefault, } local listening, listenAt, listenToken, savedSel = false, 0, nil, nil local justBound = 0 -- on-screen button for touch players (styled, moved and locked by the player) local action if o.TouchButton ~= false then action = win:_addAction(o) action.OnChange = function(state) if o.Flag then Blocks.Flags[o.Flag .. "Touch"] = table.clone(state) end end action.Apply() end obj.TouchButton = action local function label(parent, str) text(parent, { Text = str, Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 13, Stroke = 1.5, }) end local function render() for _, holder in ipairs({ keyContent, padContent, touchContent }) do holder:ClearAllChildren() end label(keyContent, listening and "..." or keyName(obj.Value)) if listening then label(padContent, "...") elseif obj.Gamepad then glyph(padContent, obj.Gamepad, 22, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5) }) else label(padContent, "None") end label(touchContent, "Edit") end -- show only the slots that make sense on this device (updates when a pad connects) local function layoutSlots() local kb, pad, touch = UserInputService.KeyboardEnabled, UserInputService.GamepadEnabled, UserInputService.TouchEnabled keyBtn.Visible = kb or (not touch and not pad) padBtn.Visible = pad or (kb and not touch) touchBtn.Visible = (touch or Blocks.ShowTouchButtons == true) and action ~= nil local w = 0 for _, b in ipairs({ keyBtn, padBtn, touchBtn }) do if b.Visible then w += b.Size.X.Offset + 6 end end title.Size = UDim2.new(1, -24 - w, 0, 40) end local function stopListening() listening = false listenToken = nil if Blocks._listening == obj then Blocks._listening = nil end justBound = os.clock() render() local restore = savedSel savedSel = nil if restore and restore.Parent then task.delay(0.12, function() GuiService.SelectedObject = restore end) end end local function startListening() if Blocks._listening or os.clock() - justBound < 0.35 then return end listening = true listenAt = os.clock() Blocks._listening = obj -- park controller selection so the pressed button doesn't also move or click the UI savedSel = GuiService.SelectedObject if savedSel then GuiService.SelectedObject = nil end render() local token = {} listenToken = token task.delay(6, function() if listenToken == token then stopListening() end end) end function obj:Set(v, silent) if isPadKey(v) then return self:SetGamepad(v, silent) end self.Value = v render() if o.Flag then Blocks.Flags[o.Flag] = v end if o.Changed and not silent then task.spawn(o.Changed, v, "Keyboard") end end function obj:SetGamepad(v, silent) self.Gamepad = v render() if o.Flag then Blocks.Flags[o.Flag .. "Pad"] = v end if o.Changed and not silent then task.spawn(o.Changed, v, "Gamepad") end end -- Restyle the on-screen button from code or a saved config: a table with any of -- Shown, Shape, Size, Color, Mode, Label, Locked, X, Y (X / Y are 0-1 screen fractions). function obj:SetTouch(state) if not action then return end if type(state) == "boolean" then state = { Shown = state } end if type(state) == "table" then action.Set(state) end end function obj:SetTouchShown(on) self:SetTouch({ Shown = on ~= false }) end function obj:EditTouch() win:EditTouchButton(action) end keyBtn.Activated:Connect(startListening) padBtn.Activated:Connect(startListening) touchBtn.Activated:Connect(function() obj:EditTouch() end) table.insert(win.Maid, UserInputService.InputBegan:Connect(function(input, processed) local kc = input.KeyCode if kc == Enum.KeyCode.Thumbstick1 or kc == Enum.KeyCode.Thumbstick2 then return end local pad = isPadKey(kc) local keyboard = input.UserInputType == Enum.UserInputType.Keyboard if not pad and not keyboard then return end if listening then if os.clock() - listenAt < 0.2 then return end if keyboard then if kc == Enum.KeyCode.Backspace or kc == Enum.KeyCode.Delete then obj:Set(nil) elseif kc ~= Enum.KeyCode.Escape then obj:Set(kc) end elseif kc == Enum.KeyCode.ButtonSelect then obj:SetGamepad(nil) else obj:SetGamepad(kc) end stopListening() return end if processed or Blocks._listening then return end if (keyboard and obj.Value and kc == obj.Value) or (pad and obj.Gamepad and kc == obj.Gamepad) then if o.Callback then task.spawn(o.Callback, kc) end end end)) table.insert(win.Maid, UserInputService.InputEnded:Connect(function(input) if not o.Released or listening then return end local kc = input.KeyCode if (obj.Value and kc == obj.Value) or (obj.Gamepad and kc == obj.Gamepad) then task.spawn(o.Released, kc) end end)) table.insert(win.Maid, UserInputService.GamepadConnected:Connect(function() layoutSlots() render() end)) table.insert(win.Maid, UserInputService.GamepadDisconnected:Connect(layoutSlots)) layoutSlots() render() if o.Flag then Blocks._items[o.Flag .. "Pad"] = { Set = function(_, v) obj:SetGamepad(v) end, } Blocks._items[o.Flag .. "Touch"] = { Set = function(_, v) obj:SetTouch(v) end, } Blocks.Flags[o.Flag .. "Pad"] = obj.Gamepad Blocks.Flags[o.Flag .. "Touch"] = action and table.clone(action.State) or nil end return register(obj, o) end function Tab:AddColorPicker(o) local row = self:_row(40) row.ClipsDescendants = true rowTitle(row, o.Name, 70) local swatch = new("TextButton", { AutoButtonColor = false, Text = "", BorderSizePixel = 0, Position = UDim2.new(1, -60, 0, 7), Size = UDim2.fromOffset(48, 26), Parent = row, }, { corner(5), stroke(2.5) }) local sv = new("TextButton", { AutoButtonColor = false, Text = "", BorderSizePixel = 0, Position = UDim2.fromOffset(12, 46), Size = UDim2.new(1, -150, 0, 110), Parent = row, }, { stroke(2.5) }) new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Size = UDim2.fromScale(1, 1), Parent = sv }, { new("UIGradient", { Transparency = NumberSequence.new(0, 1) }), }) new("Frame", { BackgroundColor3 = rgb(0, 0, 0), BorderSizePixel = 0, Size = UDim2.fromScale(1, 1), Parent = sv }, { new("UIGradient", { Rotation = 90, Transparency = NumberSequence.new(1, 0) }), }) local svDot = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Size = UDim2.fromOffset(10, 10), Parent = sv, }, { corner(3), stroke(2) }) local hueKeys = {} for i = 0, 6 do table.insert(hueKeys, ColorSequenceKeypoint.new(i / 6, Color3.fromHSV(i / 6, 1, 1))) end local hueBar = new("TextButton", { AutoButtonColor = false, Text = "", BackgroundColor3 = WHITE, BorderSizePixel = 0, Position = UDim2.new(1, -126, 0, 46), Size = UDim2.fromOffset(20, 110), Parent = row, }, { stroke(2.5), new("UIGradient", { Rotation = 90, Color = ColorSequence.new(hueKeys) }) }) local hueDot = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0), Size = UDim2.new(1, 6, 0, 6), Parent = hueBar, }, { corner(2), stroke(2) }) local hexBox = new("TextBox", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.new(1, -94, 0, 46), Size = UDim2.fromOffset(82, 26), FontFace = FONT, TextSize = 12, TextColor3 = WHITE, ClearTextOnFocus = false, Parent = row, }, { corner(5), stroke(2.5) }) local obj = { Frame = row, Type = "ColorPicker", Open = false } local h, s, v = (o.Default or WHITE):ToHSV() local function render() obj.Value = Color3.fromHSV(h, s, v) swatch.BackgroundColor3 = obj.Value sv.BackgroundColor3 = Color3.fromHSV(h, 1, 1) svDot.Position = UDim2.fromScale(s, 1 - v) hueDot.Position = UDim2.fromScale(0.5, h) hexBox.Text = "#" .. string.upper(obj.Value:ToHex()) end function obj:Set(color, silent) if typeof(color) ~= "Color3" then return end h, s, v = color:ToHSV() render() setFlag(self, o, silent) end onDrag(self.Window.Maid, sv, function(x, y) s, v = x, 1 - y render() setFlag(obj, o) end) onDrag(self.Window.Maid, hueBar, function(_, y) h = y render() setFlag(obj, o) end) hexBox.FocusLost:Connect(function() local ok, color = pcall(Color3.fromHex, hexBox.Text) if ok then obj:Set(color) else render() end end) local win = self.Window local function setOpen(open) obj.Open = open sv.Visible, hueBar.Visible, hexBox.Visible = open, open, open tw(row, 0.18, { Size = UDim2.new(1, 0, 0, open and 168 or 40) }) if win:_inWindow() then GuiService.SelectedObject = open and sv or swatch end end swatch.Activated:Connect(function() setOpen(not obj.Open) end) gamepadAdjust(sv, true, true, function(dx, dy) s = math.clamp(s + dx * 0.04, 0, 1) v = math.clamp(v - dy * 0.04, 0, 1) render() setFlag(obj, o) end) gamepadAdjust(hueBar, false, true, function(_, dy) h = math.clamp(h + dy * 0.02, 0, 1) render() setFlag(obj, o) end) sv.Visible, hueBar.Visible, hexBox.Visible = false, false, false render() return register(obj, o) end function Tab:AddProgress(o) local row = self:_row(58) rowTitle(row, o.Name).Size = UDim2.new(1, -24, 0, 34) local track = new("Frame", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.fromOffset(12, 32), Size = UDim2.new(1, -24, 0, 18), Parent = row, }, { corner(5), stroke(2.5) }) local fill = brick("Frame", { Size = UDim2.fromScale(0, 1), Parent = track }, o.Color or "Green", 0) local label = text(track, { Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 13, }) local obj = { Frame = row, Type = "Progress" } function obj:Set(value, max) max = max or o.Max or 100 self.Value = value tw(fill, 0.2, { Size = UDim2.fromScale(math.clamp(value / max, 0, 1), 1) }) label.Text = string.format("%s / %s", tostring(value), tostring(max)) end obj:Set(o.Default or 0) return obj end -- Gradient card: icon + title + text on a two-hue gradient, with an optional button. -- { Title, Content, Icon, Color | Gradient = { c1, c2 }, Height, CopyText, Button = { Name, Color, Callback } } -- With CopyText the button swaps the text for a selectable box holding it (games cannot -- write to the clipboard, so the player presses Ctrl+C or uses the touch Copy menu). function Tab:AddCard(o) local h = o.Height or 76 local row = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, h), LayoutOrder = self:_next(), Parent = self.Page, }, { stroke(3) }) local grad = new("UIGradient", { Rotation = 25, Parent = row }) themed(function(t) if o.Gradient then grad.Color = ColorSequence.new(o.Gradient[1], o.Gradient[2]) else grad.Color = hueGradient(resolveColor(o.Color, t)) end end) studs(row, self.Width, h) new("Frame", { BackgroundColor3 = WHITE, BackgroundTransparency = 0.6, BorderSizePixel = 0, Size = UDim2.new(1, 0, 0, 2), Parent = row, }) local x = 14 if o.Icon then iconLabel(row, o.Icon, { Position = UDim2.new(0, 12, 0.5, -24), Size = UDim2.fromOffset(48, 48) }) x = 72 end local right = o.Button and 134 or 14 local title = text(row, { Text = o.Title or "", Position = UDim2.new(0, x, 0.5, -27), Size = UDim2.new(1, -x - right, 0, 22), TextSize = 18, TextScaled = true, Stroke = 2.5, }) new("UITextSizeConstraint", { MaxTextSize = 17, MinTextSize = 9, Parent = title }) local content = text(row, { Text = o.Content or "", Position = UDim2.new(0, x, 0.5, -3), Size = UDim2.new(1, -x - right, 0, 30), TextSize = 12, TextWrapped = true, TextYAlignment = Enum.TextYAlignment.Top, Stroke = 1.5, }) local linkBox if o.CopyText then linkBox = new("TextBox", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.new(0, x, 0.5, 1), Size = UDim2.new(1, -x - right, 0, 22), FontFace = FONT, TextSize = 12, TextColor3 = WHITE, Text = o.CopyText, TextEditable = false, ClearTextOnFocus = false, TextXAlignment = Enum.TextXAlignment.Left, ClipsDescendants = true, Visible = false, Parent = row, }, { stroke(2), new("UIPadding", { PaddingLeft = UDim.new(0, 6), PaddingRight = UDim.new(0, 6) }) }) end if o.Button then local pos = UDim2.new(1, -122, 0.5, -19) new("Frame", { BackgroundColor3 = INK, BorderSizePixel = 0, Position = pos + UDim2.fromOffset(0, 5), Size = UDim2.fromOffset(110, 34), Parent = row, }, { stroke(3) }) local face = brick("TextButton", { Position = pos, Size = UDim2.fromOffset(110, 34), Parent = row }, o.Button.Color or "Green") text(face, { Text = o.Button.Name or "Open", Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 14, }) pressable(face) face.Activated:Connect(function() if linkBox then content.Visible = false linkBox.Visible = true task.wait() linkBox:CaptureFocus() linkBox.SelectionStart = 1 linkBox.CursorPosition = #linkBox.Text + 1 local touch = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled Blocks:Notify({ Title = "Link selected", Content = touch and "Hold the link, then tap Copy." or "Press Ctrl+C to copy it.", Type = "Success", Duration = 3, }) end if o.Button.Callback then task.spawn(o.Button.Callback) end end) end return { Frame = row, SetTitle = function(_, v) title.Text = v end, SetContent = function(_, v) content.Text = v end, } end -- "Join our Discord" card. { Invite = "discord.gg/abc", Title, Content, ButtonText, Color, Icon, Callback } function Tab:AddDiscord(o) o = o or {} return self:AddCard({ Title = o.Title or "Join our Discord", Content = o.Content or "Updates, giveaways and support", Icon = o.Icon or "Discord", Color = o.Color or rgb(88, 101, 242), CopyText = o.Invite or "discord.gg/yourinvite", Button = { Name = o.ButtonText or "Copy link", Color = o.ButtonColor or "Green", Callback = o.Callback }, }) end -- Change lines: "+ added" is green, "- removed" is red, "* changed" is yellow, anything else is plain. local CHANGE_COLORS = { ["+"] = GREEN, ["-"] = RED, ["*"] = YELLOW } local function changeLines(parent, changes, order, z) for i, entry in ipairs(changes or {}) do local color = CHANGE_COLORS[string.sub(entry, 1, 1)] local body = entry if color then body = string.gsub(string.sub(entry, 2), "^%s+", "") end local rowF = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, LayoutOrder = order + i, ZIndex = z, Parent = parent, }) new("Frame", { BackgroundColor3 = color or SUB, BorderSizePixel = 0, Position = UDim2.fromOffset(2, 4), Size = UDim2.fromOffset(7, 7), ZIndex = z, Parent = rowF, }, { stroke(1.5) }) text(rowF, { Text = body, Position = UDim2.fromOffset(18, 0), Size = UDim2.new(1, -18, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, TextSize = 13, TextWrapped = true, TextTruncate = Enum.TextTruncate.None, TextYAlignment = Enum.TextYAlignment.Top, Stroke = 1.5, ZIndex = z, }) end end -- One changelog entry. { Version, Title, Date, Changes = { "+ ...", "- ...", "* ..." }, Color } function Tab:AddUpdate(o) local row = self:_row(0) row.AutomaticSize = Enum.AutomaticSize.Y new("UIListLayout", { Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder, Parent = row }) new("UIPadding", { PaddingTop = UDim.new(0, 10), PaddingBottom = UDim.new(0, 12), PaddingLeft = UDim.new(0, 12), PaddingRight = UDim.new(0, 12), Parent = row, }) local head = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 24), LayoutOrder = 1, Parent = row }) local tag = brick("Frame", { Size = UDim2.fromOffset(84, 22), Parent = head }, o.Color, 2) text(tag, { Text = o.Version or "v1.0", Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 13, }) text(head, { Text = o.Title or "", Position = UDim2.fromOffset(94, 0), Size = UDim2.new(1, -194, 1, 0), TextSize = 15, }) text(head, { Text = o.Date or "", Position = UDim2.new(1, -100, 0, 0), Size = UDim2.fromOffset(100, 24), TextXAlignment = Enum.TextXAlignment.Right, TextSize = 12, TextColor3 = SUB, Stroke = 1.5, }) changeLines(row, o.Changes, 1, 1) return { Frame = row } end -- Announcement popup with a "Don't show again" tick box. -- { Id, Title, Icon, Content, Changes, ButtonText, Color, DontShowAgain = true, Hidden, OnClose(dontShowAgain) } -- It is remembered for this session by Id. To remember it across sessions, save the value -- OnClose gives you (for example in a DataStore) and pass it back as Hidden next time. Blocks._dismissed = {} function Window:Popup(o) local id = o.Id or o.Title or "popup" if o.Hidden or Blocks._dismissed[id] then return false end local overlay = new("TextButton", { AutoButtonColor = false, Selectable = false, Text = "", BackgroundColor3 = INK, BackgroundTransparency = 1, BorderSizePixel = 0, Position = UDim2.fromOffset(0, HEADER_H), Size = UDim2.new(1, 0, 1, -HEADER_H), ZIndex = 30, Parent = self.Main, }) tw(overlay, 0.15, { BackgroundTransparency = 0.4 }) local W = math.min(400, self.Root.Size.X.Offset - 40) local card = new("Frame", { BackgroundColor3 = WHITE, BorderSizePixel = 0, AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(W, 0), AutomaticSize = Enum.AutomaticSize.Y, ZIndex = 31, Parent = overlay, }, { stroke(3), new("UIGradient", { Rotation = 90, Color = BODY }) }) local pop = new("UIScale", { Scale = 0.7, Parent = card }) trapSelection(card) tw(pop, 0.25, { Scale = 1 }, Enum.EasingStyle.Back) local head = brick("Frame", { Size = UDim2.new(1, 0, 0, 40), ZIndex = 31, Parent = card }, o.Color) studs(head, W, 40).ZIndex = 31 local x = 12 if o.Icon then iconLabel(head, o.Icon, { Position = UDim2.new(0, 8, 0.5, -14), Size = UDim2.fromOffset(28, 28), ZIndex = 32 }) x = 44 end text(head, { Text = o.Title or "What's new", Position = UDim2.fromOffset(x, 0), Size = UDim2.new(1, -x - 10, 1, 0), TextSize = 20, Stroke = 2.5, ZIndex = 32, }) local body = new("Frame", { BackgroundTransparency = 1, Position = UDim2.fromOffset(0, 40), Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, ZIndex = 31, Parent = card, }, { new("UIListLayout", { Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }), new("UIPadding", { PaddingTop = UDim.new(0, 12), PaddingBottom = UDim.new(0, 16), PaddingLeft = UDim.new(0, 14), PaddingRight = UDim.new(0, 14), }), }) if o.Content and o.Content ~= "" then text(body, { Text = o.Content, Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, TextSize = 14, TextWrapped = true, TextTruncate = Enum.TextTruncate.None, TextYAlignment = Enum.TextYAlignment.Top, Stroke = 1.5, ZIndex = 32, LayoutOrder = 1, }) end changeLines(body, o.Changes, 1, 32) local dontShow = false if o.DontShowAgain ~= false then local tick = new("TextButton", { AutoButtonColor = false, Text = "", BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 24), ZIndex = 32, LayoutOrder = 200, Parent = body, }) local box = new("Frame", { BackgroundColor3 = SLOT, BorderSizePixel = 0, Position = UDim2.fromOffset(2, 2), Size = UDim2.fromOffset(20, 20), ZIndex = 32, Parent = tick, }, { stroke(2.5) }) local mark = iconLabel(box, "Check", { Size = UDim2.fromScale(1, 1), Visible = false, ZIndex = 33 }) text(tick, { Text = "Don't show again", Position = UDim2.fromOffset(32, 0), Size = UDim2.new(1, -32, 1, 0), TextSize = 13, TextColor3 = SUB, Stroke = 1.5, ZIndex = 32, }) tick.Activated:Connect(function() dontShow = not dontShow mark.Visible = dontShow end) end local holder = new("Frame", { BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 40), ZIndex = 31, LayoutOrder = 201, Parent = body, }) new("Frame", { BackgroundColor3 = INK, BorderSizePixel = 0, Position = UDim2.fromOffset(0, 5), Size = UDim2.new(1, 0, 0, 35), ZIndex = 31, Parent = holder, }, { stroke(3) }) local face = brick("TextButton", { Size = UDim2.new(1, 0, 0, 35), ZIndex = 32, Parent = holder }, o.ButtonColor or "Green") face.BevelTop.ZIndex = 32 face.BevelBottom.ZIndex = 32 text(face, { Text = o.ButtonText or "Got it", Size = UDim2.fromScale(1, 1), TextXAlignment = Enum.TextXAlignment.Center, TextSize = 17, Stroke = 2.5, ZIndex = 33, }) pressable(face) local function close() self:_closeModal() overlay:Destroy() if dontShow then Blocks._dismissed[id] = true end if o.OnClose then task.spawn(o.OnClose, dontShow) end end face.Activated:Connect(close) self:_openModal(face, close) return true end function Blocks:Destroy() for _, win in ipairs(table.clone(self._windows)) do win:Destroy() end local pg = Players.LocalPlayer:FindFirstChild("PlayerGui") local notifs = pg and pg:FindFirstChild("BlocksUI_Notifications") if notifs then notifs:Destroy() end if self._adjustConn then self._adjustConn:Disconnect() self._adjustConn = nil adjustHooked = false table.clear(adjusters) ContextActionService:UnbindAction("BlocksUI_Adjust") end table.clear(self._themed) table.clear(self._items) table.clear(self.Flags) end -- Loadstring support: running the source again (re-executing a loadstring) replaces the -- previous copy instead of stacking a second set of windows and input hooks. -- Set shared.BlocksUI_KeepOld = true before loading to keep the old copy alive. do local previous = shared.BlocksUI if previous and previous ~= Blocks and not shared.BlocksUI_KeepOld and type(previous.Destroy) == "function" then pcall(previous.Destroy, previous) end shared.BlocksUI = Blocks end return Blocks