I made a script that if I hover over button a frame is visible and if I dont hover its not visible which works but I wanted the position of the frame to be the position of the mouse, so I got the position of the mouse and changed the frame postiion tp the mouse position but it doesnt work, any help?
local Players = game:GetService("Players")
local Gui = script.Parent.Hard
local InfoGui = script.Parent.HardHover
local Entered = false
Gui.MouseEnter:Connect(function()
Entered = true
InfoGui.Visible = true
end)
Gui.MouseLeave:Connect(function()
Entered = false
InfoGui.Visible = false
end)
This script doesn nothing. I need the script to when I hover over a button the frame is next to them mouse, following it. Your script doesnt follow and only works once.
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
mouse.Move:Connect(function()
frame.Position = UDim2.fromOffset(mouse.X, mouse.Y) --will set to on the mouse, adjust as needed
end)
local Gui = script.Parent.Hard
local InfoGui = script.Parent.HardHover
local Entered = false
local function updateInfoGuiPosition(mousePosition)
local offsetX = -10
local offsetY = -30
local mouseX = mousePosition.X
local mouseY = mousePosition.Y
InfoGui.Position = UDim2.new(-0.29, mouseX + offsetX, -1.65, mouseY + offsetY)
end
Gui.MouseEnter:Connect(function()
Entered = true
InfoGui.Visible = true
end)
Gui.MouseLeave:Connect(function()
Entered = false
InfoGui.Visible = false
end)
game:GetService("UserInputService").InputChanged:Connect(function(input)
if Entered and input.UserInputType == Enum.UserInputType.MouseMovement then
updateInfoGuiPosition(input.Position)
end
end)