I want to make a textbox appear next to my mouse when I right click. This is the code I have but it is not working. It is a local script in starter player scripts.
wait(1)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local popup = player.PlayerGui.screen.test
local x = mouse.Hit.X
local y = mouse.Hit.Y
mouse.Button1Down:connect(function()
popup.Visible = false
player.Character.Humanoid:MoveTo(mouse.Hit.p)
end)
mouse.Button2Down:connect(function()
popup.Visible = false
popup.Position = UDim2.new(x, y)
popup.Visible = true
end)

2 comments
try UDim2.new(x,0,y,0) or UDim2.new(0,x,0,y)
I tried UDim2.new(0,x,0,y) the first time, and it seems to work in that it fully cycles through the function, but it does not update the position. Using UDim2.new(x, y) or UDim2.new(x,0,y,0) gets to the first line and stops when it reaches the second, leaving it not visible and not changing the position.