When I hover my cursor over a button with a custom cursor it goes away

Hello I was wondering if anyone can help me fix this problem where if I hover my cursor over a button with an already applied custom cursor it wont show while hovering over the button here is my code

local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = 'http://www.roblox.com/asset/?id=172802980'

The “Active” property seems to do this, but only as long as the button is not clicked
I would personally just make an artificial mouse

what is a artificial mouse? And how would I go about making one?

Make the mouse invisible. On renderstepped, position an image label of the mouse always at your mouse position. Done.

1 Like

alright ill do some research into this thanks for the help.

1 Like

Ive looked at fake mouse stuff and there is not a lot of documentation can someone give me something to help me?

The reason it’s happening is because when you hover over a button, it’ll change your mouse.

You should use MouseEnter and MouseLeave to change the player’s mouse.

Example:

local mouse = game.Players.LocalPlayer:GetMouse()
script.Parent.MouseEnter:Connect(function()
-- set their mouse
end)

Of course, if you have a lot of buttons, that’s an incredibly inefficient way to do things.

Im not sure I understand what this function does but thank you.

I had the same problem too. I easily solved by making the cursor invisible and creating an ImageLabel (let’s call it X), then through RunService.RenderStepped, kept setting the position of X to the mouse’s position. To get the position of the mouse on the screen, you can use UserInputService:GetMouseLocation().

1 Like

alright ill look into this ive tried this before but my problem is the cursor is way offcentered

Sorry for not explaning it haha.

This code should be in a LocalScript.

-- a local script always has the local player, basically the client.
-- it's getting the local player, and then their mouse.
local mouse = game.Players.LocalPlayer:GetMouse()

-- MouseEnter is basically when the player starts hovering over the object
-- we want the code to run when the player hovers over the button
script.Parent.MouseEnter:Connect(function()
-- set their mouse
mouse.Icon = "YourId"
end)

since when you hover over a button it sets your mouse to something, we make it change back to the thing you want.

So ive tried this and this is my code my problem being idk how to fix the offset because its hugely offset from the mouse

local uis = game:GetService('UserInputService')
local id = "rbxassetid://73737626"
uis.MouseIconEnabled = true
local image = script.Parent
local runService = game:GetService('RunService')

function renderStepped()
    local mouseLocation = uis:GetMouseLocation()
    image.Position = UDim2.new(0, mouseLocation.X,0, mouseLocation.Y)
end

runService.RenderStepped:Connect(renderStepped)

and its offset a little to the right and below it

1 Like

Try setting the mouse image’s AnchorPoint to 0.5, 0.5 so it is perfectly centered no matter what.

3 Likes

Alright ill try it and see if it works

1 Like

Alright I fiddled with it and it works! Thanks a lot your a big help!

1 Like

(Sorry for the bump)
I’ve made some changes to your script. It now works perfectly as intended and it’s cleaner.

local UIS = game:GetService('UserInputService')
local RS = game:GetService('RunService')

function renderStepped()
	local mouseLocation = UIS:GetMouseLocation()
	image.Position = UDim2.new(0, mouseLocation.X,-0.05, mouseLocation.Y)
end

RS.RenderStepped:Connect(renderStepped)
UIS.MouseIconEnabled = false
4 Likes

doesnt work I tried this:




local UIS = game:GetService('UserInputService')
local RS = game:GetService('RunService')
local image = script.Parent

function renderStepped()
	local mouseLocation = UIS:GetMouseLocation()
	image.Position = UDim2.new(0, mouseLocation.X,-0.05, mouseLocation.Y)
end

RS.RenderStepped:Connect(renderStepped)
UIS.MouseIconEnabled = false