I am trying to make a Frame follow the mouse cursor, but the frame is too far away from the Mouse Cursor.
This is my code:
local Mouse = game.Players.LocalPlayer:GetMouse()
local hovering = false
local button = script.Parent
local Frame = button.Frame
button.MouseEnter:Connect(function()
hovering = true
end)
game:GetService("RunService").RenderStepped:Connect(function()
local X = Mouse.X
local Y = Mouse.Y
if Frame then
if hovering == true then
Frame.Visible = true
Frame.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
else
Frame.Visible = false
end
end
end)
button.MouseLeave:Connect(function()
hovering = false
end)