Hey Devs! Today I’ll show you Avatar Context Menu. This is a very good and unique option that you can add to your game. It could be good for a hangout game or even a simulator, tycoon, obby etc. This feature is very forgotten and it was released in 2018 so that’s why it is very unique and also very easy to implement. Don’t worry it is still updated. This is the first post about this feature THIS YEAR lol.
What is the Avatar Context Menu?
Avatar Context Menu is a menu with different options. When you click on a player, a menu appears.
(The image of the player is not showing in Studio).
This menu contains a few options like chatting with the player, waving to them, viewing or sending a friend request to them. You can also change the selected player. The menu is fully customizable, so you can add your own options or change the colors and sizes, etc. If you’re making a simulator, you could add the option to trade, or in RPG’s you could add a “Stats” option which would show the player’s stats.
How to add it?
Avatar Context Menu can be turned on by making a Localscript in StarterPlayerScripts.
Script:
local StarterGui = game:GetService("StarterGui") StarterGui:SetCore("AvatarContextMenuEnabled", true)
and that’s it.
Customizing the menu
That’s my favorite part! Because the menu is fully customizable, you can remove all the default options and make your own!
For starters, I will remove the “Wave” option.
Because it’s a default action, we need to remove it by using AvatarContextMenuOption enum! When you’re making your own options you remove them in a different way.
Script:
StarterGui:SetCore("RemoveAvatarContextMenuOption", Enum.AvatarContextMenuOption.Emote)
And we got it!
Now I will be making a simple print script that will send a notification that a print was successful.
-- Referecing
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Creating a BindableEvent and actions after we click the button.
local bindableEvent = Instance.new("BindableEvent")
local function onCustomACMAction(targetPlayer)
StarterGui:SetCore("SendNotification", {
Title = "ACM Notification!";
Text = "You successfully printed something."
})
print("Player " .. player.Name .. " printed something from " .. targetPlayer.Name .. " in AvatarContextMenu")
print("Something.")
end
bindableEvent.Event:Connect(onCustomACMAction)
local options = {"Print something!", bindableEvent} -- We can set here the name of our button.
StarterGui:SetCore("AddAvatarContextMenuOption", options)
Everything here is done locally! You need to make events if you want something to happen on the server.
And after we click the button we get our two prints in the console and the notification.
More Customization
I will customize the menu more so it looks better and more unique!
If you want more customization options check out the DevHub Article.
Script:
StarterGui:SetCore("AvatarContextMenuTheme", {
BackgroundTransparency = 0,
BackgroundColor = Color3.fromRGB(19, 255, 15),
NameTagColor = Color3.fromRGB(255, 0, 4),
NameUnderlineColor = Color3.fromRGB(213, 233, 255),
ButtonFrameColor = Color3.fromRGB(255, 119, 8),
ButtonFrameTransparency = 0.7,
ButtonUnderlineColor = Color3.fromRGB(213, 233, 255),
Font = Enum.Font.SourceSansBold
})
It looks terrible now…
Links:
Avatar Context Menu Article
Thanks!