Hello Everyone, so I was trying to make a movable frame for my game, like when mouse hovering a button, it would show you a hint, and that hint frame, would move when mouse moving.
But I have a problem with making it, it’s not really accurate… Like it is moving, but it’s not beside the cursor, can someone help me please?
Here is the script:
local move_frm = script.Parent.Move
clone.Button.MouseEnter:Connect(function()
if clone.Locked.Visible then
local mouseMoveConnection
move_frm.Visible = true; currentlyHoveredButton = clone
mouseMoveConnection = mouse.Move:Connect(function()
if currentlyHoveredButton == clone then
local camera = workspace.CurrentCamera
local screenSize = camera.ViewportSize
local offsetX = move_frm.AbsoluteSize.X / 2
local offsetY = move_frm.AbsoluteSize.Y + 20
local newX = math.clamp(mouse.X - offsetX, 0, screenSize.X - move_frm.AbsoluteSize.X)
local newY = math.clamp(mouse.Y - offsetY, 0, screenSize.Y - move_frm.AbsoluteSize.Y)
move_frm.Position = UDim2.fromOffset(newX, newY)
else
if mouseMoveConnection then
mouseMoveConnection:Disconnect()
mouseMoveConnection = nil
end
end
end)
local treasuresSpace: Folder? = workspace.Main:WaitForChild("Treasures")
local hint = treasuresSpace[name].Hint
move_frm.Main.Text = hint.Value
end
end)
clone.Button.MouseLeave:Connect(function()
if currentlyHoveredButton == clone then
move_frm.Main.Text = "{Hint}"
move_frm.Visible = false
currentlyHoveredButton = nil
end
end)
If someone can help, that would be really appreciated! Thanks.