#Mouse position on screen

1 messages · Page 1 of 1 (latest)

torn ether
#

I'm trying to make a tooltip on screen when you hover over a button inside a SurfaceGui but don't know how to get the mouse position on screen. Player:GetMouse() returns it's position on the surface gui

speed.BuyButton.MouseEnter:Connect(function()
    local mouse = Player:GetMouse()
    Tooltip.Parent = GUI
    
    Tooltip.Position = UDim2.fromOffset(mouse.X,mouse.Y+58)
    print(Tooltip.Position)
end)
wicked mica
#

you should be able to use .mousebuttonentered

#

or something like that

#

i forgot

#

let me check

torn ether
#

idk what you mean

wicked mica
#

this is what i meant

abstract pumice
#

can we see the tooltip gui?

wicked mica
#

he just needs .mouseenter and .mouseleave

torn ether
#

no, i just need the mouse position on screen

blissful topazBOT
#

studio** You are now Level 8! **studio

wicked mica
#

just use .MouseEnter

#

way easier

torn ether
#

i need to set the tooltip position to the mouse position

wicked mica
#

oh i didnt even read the script you sent

#

my bad

torn ether
#

the issue is that .MouseEnter and mouse.X/Y give a position relative to the surface gui's top left corner

#

and i need a position relative to the screen's any corner

#

now i'm reading that the PlayerMouse is supressed by userInputService

#

i'll try using that

#

okay it works now

abstract pumice
#

how'd you fix it

torn ether
#
speed.BuyButton.MouseEnter:Connect(function(x,y)
    local mouse = UIS:GetMouseLocation()
    Tooltip.Parent = GUI
    
    Tooltip.Position = UDim2.fromOffset(mouse.x,mouse.y)
    print(Tooltip.Position)
end)
#

swapped Player:GetMouse() with UserInputService:GetMouseLocation()