Use with scripts
Using the Host GUI in your scripts requires some scripting knowledge.
You can use the API module script to make the GUI appear with your scripts.
Use the API
To use the API, you need to require it in your script:
local api = require(game:GetService("ServerScriptService").HostGui.Scripts.Api)
Send messages
To display a message on the GUI, use the :SendMessage()
method. The method takes 3 arguments:
author
:string
- the username that will appear as the author of the messagemessage
:string
- the message that will appearconfig
:MessageSettings
- the settings to use for that message, this argument is optional
MessageSettings
include:
IgnoreOverrides
:boolean?
- iftrue
, theNames
andImages
settings will be ignoredImage
:(string | false)?
- the image to display, can be an image URI (rbxassetid://123123123
) orfalse
to disable the image entirelyAnimation
:string?
- the per-letter animation to use when displaying the message. Can be the same as theTextAnimation
settingObject
:PVInstance?
- can be a part or a model, used to calculate which side of the screen the GUI should go on when there are more than 1 visibleNameToUseForOverrideCheck
:string?
- if the display name should be different to the name used in settings, this is the name to use in the settings
Example usage:
api:SendMessage("Stacy", "hello")
api:SendMessage("gabys2005", "This is a very important message", {
IgnoreOverrides = true
}) -- will ignore the 'Names' and 'Images' settings
api:SendMessage("idezye", "Join our Discord server", {
Image = "rbxassetid://117544468380431",
Animation = "Rainbow",
Object = workspace.idezye
}) -- the message will contain an image, will use the Rainbow animation and will use idezye's character for positioning
Check if a player's messages will appear on the GUI
You can check if a player selected their 'broadcast' button by using the :IsPlayerActive()
method. The method uses user IDs and returns true
or false
:
local isActive = api:IsPlayerActive(game.Players.gabys2005.UserId)
Get the whitelist
You can use the :GetWhitelist()
method to get the whitelist object. Please note that this is not a table, but an object with its own methods:
whitelist:IsWhitelisted(player: Player)
allows you to check if a player is whitelistedwhitelist.WhitelistChanged:Connect(player: Player, isWhitelisted: boolean)
allows you to listen for whitelist changes
local whitelist = api:GetWhitelist()
local isIdezyeWhitelisted = whitelist:IsWhitelisted(game.Players.idezye)
whitelist.WhitelistChanged:Connect(function(player, isWhitelisted)
print(`{player.Name}'s whitelist status changed to: {isWhitelisted}`)
end)
Get a clean version of text using rich syntax
You can use custom rich text syntax in your messages (it's explained below). You can use the :GetCleanText()
method to clean a string of any rich text syntax
local clean = api:GetCleanText("This sentence will have a {color:0 255 0}green {bold}bold{reset} word in the middle of it.")
print(clean) -- This sentence will have a green bold word in the middle of it.
Rich Text syntax
The Host GUI uses a custom rich text syntax, allowing you to make parts of text bold, italic, colourful and more. Rich text is useful mostly for NPCs, because you can display a different message on the chat bubble and the Host GUI. Here are all the possible options:
{bold}This text will be in bold
{cursive}This text will be cursive
{color:255 0 0}This text will be red
{anim:Rainbow}This text will have a rainbow animation
{anim:Tilt}This text will have a tilt animation
{anim:Shake}This text will have a shake animation
{eanim:Fade}This text will fade in
{eanim:Jump}This text will jump in
{eanim:Rainbow}This text will use a rainbow to show up
{eanim:Shake}This text will shake into place
...{reset}This text will have all of it's formatting reset
Any formatting created before {reset} will be forgotten
This sentence will have a {color:0 255 0}green {bold}bold{reset} word in the middle of it.
Example
If you want to display a message from an NPC, for example Stacy, when a button is pressed, the script could look something like this:
local HostGui = require(game:GetService("ServerScriptService").HostGui.Api)
script.Parent.ClickDetector.MouseClick:Connect(function()
HostGui:SendMessage("Stacy", "This is a very long and complicated message")
end)