Hello! I have a custom cursor in my game, but, every time i hover over a GUI, the cursor becomes the normal bland mouse. I have tried the hover image option on these buttons, but it really just changes the picture to the mouse image. Anyone have any thoughts?
2 Likes
Not sure if there’s a better way, but I’ve just done it like this:
LocalScript located in StarterGui:
--change neutral cursor icon
neutral = 'rbxassetid://2354639945' --your neutral icon
mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = neutral
--variables
Entered = false --variable for gui hover
button = script.Parent --change to your button location
--cursor hovering on gui
button.MouseEnter:connect(function()
if Entered == false then
Entered = true
mouse.Icon = 'rbxassetid://2354640534' --your hover icon
end
end)
--cursor leaving gui
button.MouseLeave:connect(function()
if Entered == true then
Entered = false
mouse.Icon = neutral
end
end)
--clicking mouse on and off a gui
mouse.Button1Down:connect(function()
if Entered == true then --if hovering on gui then
mouse.Icon = 'rbxassetid://2359372698' --your hover click icon
wait(.1)
mouse.Icon = 'rbxassetid://2354640534' --your hover default icon
elseif Entered == false then --if out of a gui then
mouse.Icon = 'rbxassetid://2359372118' --your neutral click icon
wait(.1)
mouse.Icon = neutral
end
end)
Also note that I used this localscript for a frame (not a button gui), so if it acts weird for you on a button, try using a normal frame. I know this method for hover detection is pretty annoying, especially when you have several buttons, so let’s hope someone comes through with an easier script.
6 Likes
From what I can tell, you haven’t told the mouse to STAY as your custom cursor, so it will revert to the standard when hovered over the GUI.