Removing the defalut "ArrowCursor" when hovering over a button

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Remove the default cursor/change it to a custom one while hovering over a button. (Look at video below.)

  2. What is the issue? Include enough details if possible!

  3. What solutions have you thought of so far?
    Tried using MouseEnter and MouseLeave. Didn’t work.

1 Like

Not sure if this is what you’re looking for, but hopefully it will help. :man_shrugging:
:link: Hovering TextButton, Or Image Label Cursor Solution - Tutorial

maybe make a line in the script were you refresh the mouse to the arrow one when it changes

So after an hour or so of working with this problem, I think I found the solution. I know you mentioned that you tried MouseEnter and MouseLeave, but I was able to get those two events to work for me. Note that this method doesn’t work for pre-made Roblox Core GUI items.

So what did I do? I first created an example ScreenGui in StarterGui. I then added a localscript called “Custom Default Cursor” and then added a Frame setting the size to (1,0,1,0). After that I added a text button and added three more localscripts inside of it. I named them accordingly to the image below. Also, make sure to note that the Frame is located OUTSIDE of the “Custom Default Cursor” localscript but still inside of the Example ScreenGui.
image
above image shows what I just explained.


Now let’s move on to each localscript. Obviously there are better ways to do all of this, I just made it so I can at least understand what I’m doing. Having multiple scripts each with a specific thing to do makes it easier for me to comprehend.
Custom Default Cursor

--Creates a custom mouse icon 
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset?id=6681633156"

HideCursor

local mouse = game.Players.LocalPlayer:GetMouse()
local UIS = game:GetService("UserInputService")

script.Parent.MouseEnter:Connect(function()
	UIS.MouseIconEnabled = false
end)
script.Parent.MouseLeave:Connect(function()
	UIS.MouseIconEnabled = true
end)

ChangeCursorIcon

local mouse = game.Players.LocalPlayer:GetMouse()
local UIS = game:GetService("UserInputService")

script.Parent.MouseEnter:Connect(function()
	if not script.Parent.Parent:FindFirstChild("hoverIcon") then --Checks if hoverIcon already exists
		local hoverIcon = Instance.new("ImageLabel", script.Parent.Parent)
		local startLocation = UIS:GetMouseLocation()

		hoverIcon.Position = UDim2.fromOffset(startLocation.X, startLocation.Y) --Creates the start position where the mouse is located
		hoverIcon.Name = "hoverIconLabel"
		hoverIcon.Image = "http://www.roblox.com/asset?id=1493093173"
		hoverIcon.BackgroundTransparency = 1
		hoverIcon.BorderSizePixel = 0
		hoverIcon.Size = UDim2.new(.08,0,.08,0) --Change this to whatever size cursor works best for you
		hoverIcon.AnchorPoint = Vector2.new(0.5, 0.5) --Sets the anchor point to the EXACT center of the mouse

		Instance.new("UIAspectRatioConstraint", hoverIcon)

		while wait() do
			local mouseLocation = UIS:GetMouseLocation()
			hoverIcon.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y) --Constantly changes the position of the mouse
		end
	end
end)

script.Parent.MouseLeave:Connect(function()
	for x, v in pairs(script.Parent.Parent:GetDescendants()) do --v is the same as "Value" and in this case we are searching for anything named with "hoverIconLabel in the Frame"
		if v.Name == "hoverIconLabel" then
			v:Destroy()
		end
	end
end)

Clicked

script.Parent.MouseButton1Click:Connect(function()
	print("You clicked me!")
	
	--Do anything else here.
end)

Alright! That should hopefully help you out, I’ll also link my example studio project if you would like to see all of this in more detail.


MouseIconChangeOnHover.rbxl (27.5 KB)

2 Likes