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

SetTopbarTransparency

SetTopbarTransparency sets the transparency of the Topbar CoreGui. A value of 0 is completely opaque, and a value of 1 is completely transparent. Values outside of the range [0, 1] are clamped. The default transparency of the topbar is 0.5. The current transparency can be retrieved using the similarly-named PlayerGui/GetTopbarTransparency|GetTopbarTransparency function.

Comparison of Values

The screenshots below show the topbar at 1.0, 0.5 and 0.0 transparency.
The TopBar with a transparency of 1.0 (completely hidden)] The TopBar with a transparency of 0.5 (50% transparency)] The TopBar with a transparency of 0.0 (completely opaque)

Usage

This method is often used when re-styling the topbar to match the visual aesthetic of a game. By hiding the topbar, you can create your own custom topbar. See the code samples for an example.

Alternative

Using the StarterGui/SetCore method with the TopbarEnabled option allows you to enable/disable the entire topbar and all of its features (player list, health, etc). By contrast, this method only affects how the topbar is displayed.

Parameters

Name Type Default Description

Returns

Return Type Summary

Code Samples


Custom Topbar Style

This code sample demonstrates how you can create a custom-styled topbar. Paste it into a LocalScript placed within StarterPlayerScripts. First, hide the default topbar by setting its transparency to 1 (using PlayerGui/SetTopbarTransparency). Then, recreate the topbar Frame and parent it to a ScreenGui. Set the styles on the Frame to your liking, such as GuiObject/BackgroundColor3 or GuiObject/BackgroundTransparency. Below is a screenshot of what the topbar will look like after this code sample is run.

The Topbar customized to appear dark blue

-- Custom topbar style
local TOPBAR_COLOR = Color3.fromRGB(0, 0, 127)
local TOPBAR_TRANSPARENCY = 0

local playerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")

-- Hide the topbar
playerGui:SetTopbarTransparency(1)

-- Create a "Fake" replacement topbar with a ScreenGui and Frame
local screenGui = Instance.new("ScreenGui")
local frame = Instance.new("Frame")

-- Move (0, 0) to the actual top left corner of the screen, instead of under the topbar
screenGui.IgnoreGuiInset = true
-- The topbar is 36 pixels tall, and spans the entire width of the screen
frame.Size = UDim2.new(1, 0, 0, 36) 
-- Style the topbar
frame.BackgroundColor3 = TOPBAR_COLOR
frame.BackgroundTransparency = TOPBAR_TRANSPARENCY
frame.BorderSizePixel = 0

frame.Parent = screenGui
screenGui.Parent = playerGui

PlayerGui:SetTopbarTransparency

The following line of code makes the Topbar appear fully opaque.

game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui'):SetTopbarTransparency(0)