This right click gui script does not work

You can write your topic however you want, but you need to answer these questions:
This script is supposed to have the screengui anchor point, at the position of the mouse if the player right clicks.
This should only be possible if the mouse is inside the billboardgui.

The gui should disappear if the mouse leaves the gui but that part works.

Currently, the gui does indeed appear when the player right clicks, it just appears somewhere in the upper right corner. And the position does not change when I try again.

local menu = script.Parent.MainPart

local clickpart = script.Parent.Parent.BillboardGui.TextButton

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()


menu.Visible = true

menu.Position = UDim2.fromOffset(mouse.X, mouse.Y)



menu.Visible = false


This is a LocalScript which does not have authority over the part in Workspace. If you click it, it will only be visible to you not to anybody else in the server. You should use RemoteEvents for this. It will probably also fix the mouse position issue. Also, you didn’t ask any questions you just gave us all your problems.

oh sorry i was so busy trying to explain the problem i completely forgot to actually ask it xD