Avatar Context Menu, Can't forcefully close

Sorry if i havn’t posted this in the right section

I simply created a simple toggle button that opens / closes the “Avatar Context Menu”. The button works fine opening the menu but when i click on it again, i would have expected it to close because i was following this https://developer.roblox.com/en-us/articles/Avatar-Context-Menu#visual-customization

This is a LocalScript in the StarterGui:

local starterGui = game:GetService(“StarterGui”)
local button = script.Parent
button.MouseButton1Click:Connect(function()
if button.Text == “Enable ACM” then
starterGui:SetCore(“AvatarContextMenuTarget”, plr)
button.Text = “Disable ACM”
else
starterGui:SetCore(“AvatarContextMenuTarget”, nil)
button.Text = “Enable ACM”
end
end)

This is the output error:

[21:21:34.617 - Argument 2 missing or nil]

Which is this line:

starterGui:SetCore(“AvatarContextMenuTarget”, nil)

So i thought ok, maybe instead of setting it to nil i might need to be set to false. So i changed it:

starterGui:SetCore(“AvatarContextMenuTarget”, false)

But i got this error instead which is weird because i had just set it nil before but it threw an error as well.

[21:34:50.652 - CoreGui.RobloxGui.CoreScripts/AvatarContextMenu:408: AvatarContextMenuTarget argument must be a Player or nil]

2 Likes

This is so interesting, so it says it has to be either false or nil, and if you set it to nil it errors. This is probably a bug maybe.
Does the ACM close even though there is an error?
Maybe then try enabling and disabling it

StarterGui:SetCore("AvatarContextMenuEnabled", true)

It’s a bug with SetCore itself. SetCore will always throw this error (right now at least, not sure if this has changed recently) if the second argument is nil.

Kinda weird, too, since the core script for the avatar context menu has a condition for player == nil

No the ACM doesn’t close even with the error. I tried Enabled/Disabling but this had no effect on the outcome, still printed the same error in output.

Thanks for the report. I have filed a bug report for this and will try to get a fix out as soon as possible.

1 Like