PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

BorderSizePixel

GuiObject

int

BorderSizePixel determines how wide a UI element’s border should render, in pixels. This property and GuiObject/BorderColor3 and GuiObject/BackgroundTransparency determine how the border of a UI element should look. Setting BorderSizePixel to 0 will disable the border altogether. The border width extends outward the perimeter of the rectangle.


Code Samples


Button Highlight

This code sample causes the border of a parent GuiObject to highlight when the user hovers their mouse over the element.

-- Put me inside some GuiObject, preferrably an ImageButton/TextButton
local button = script.Parent

local function onEnter()
	button.BorderSizePixel = 2
	button.BorderColor3 = Color3.new(1, 1, 0) -- Yellow
end

local function onLeave()
	button.BorderSizePixel = 1
	button.BorderColor3 = Color3.new(0, 0, 0) -- Black
end

-- Connect events
button.MouseEnter:connect(onEnter)
button.MouseLeave:connect(onLeave)
-- Our default state is "not hovered"
onLeave()