How to Use 9-Slice in Roblox GUI: Pixel-Perfect Scaling
Updated
When resizing regular ImageLabels or ImageButtons across different screen resolutions, borders and rounded corners frequently distort into blurry, stretched artifacts. The 9-slice technique solves this by dividing an image into a 3x3 grid: four corner corners stay fixed in pixel size, the edges tile or stretch along one axis, and only the center expands. Here is how to configure SliceCenter Rect properties in Roblox Studio for razor-sharp UI containers.
Step 1: Understand 9-Slice Grid Coordinates
A 9-slice image divides a single texture into nine regions: 4 fixed corners, 4 stretchable edge borders, and 1 scalable center body. When configured with a `SliceCenter` Rect, Roblox preserves the four corners at exact pixel dimensions while dynamically repeating or stretching the edges to fit any frame size.
Generate custom sliced borders, dialogue banners, and fantasy inventory slots using the Roblox UI Maker.
Step 2: Prepare Your Image with Fixed Corner Radii
When creating your UI image in Photoshop, Figma, or Aseprite, ensure the four corners have identical corner radii (for example, 16x16 pixels). Note the exact pixel coordinates where the corners end and the straight borders begin.
- Top-Left corner end: X0 = 16, Y0 = 16
- Bottom-Right corner start: For a 64x64 image with 16px borders, X1 = 48, Y1 = 48
Step 3: Configure ScaleType and SliceCenter in Studio
- 1 Insert an ImageLabel or ImageButton into your ScreenGui.
- 2 Set the Image property to your uploaded asset ID.
- 3 In the Properties panel, change ScaleType from `Stretch` to `Slice`.
- 4 Locate the SliceCenter property. Click the drop-down and enter your Rect coordinates: `16, 16, 48, 48`.
- 5 Resize the ImageLabel to any rectangular dimension (e.g., 400x120 or 600x350). Notice how the corner curves remain perfectly round and crisp without blurring.
Step 4: Fine-Tune with SliceScale for High-DPI Displays
The `SliceScale` property allows you to multiply or shrink the thickness of your 9-slice borders. For ultra-fine borders on high-DPI mobile screens, set SliceScale to 0.75; for thick, cartoonish mobile borders, increase SliceScale to 1.5.
Roblox 9-Slice FAQ
What is SliceCenter in Roblox?
SliceCenter is a Rect property that defines the inner bounding box (X0, Y0, X1, Y1) of a 9-slice image, indicating which rectangular region is allowed to stretch while protecting the outer corners.
Why is my 9-slice texture still distorted or blurry?
Ensure your SliceCenter Rect coordinates accurately match the border width of the source image and that ScaleType is set to Slice rather than Stretch.
Does 9-slice support transparent backgrounds?
Yes. 9-slice fully supports 32-bit PNG alpha transparency, making it ideal for glassmorphism panels, floating name tags, and speech bubbles.
Can I use 9-slice on buttons as well as frames?
Yes. ImageButtons support the exact same ScaleType, SliceCenter, and SliceScale properties as ImageLabels.
What is the optimal source texture size for a 9-slice button?
Compact sizes like 64x64, 128x128, or 256x256 pixels are ideal. Because the center stretches freely, large texture dimensions only waste client memory.