Mouse Icon changes to default cursor when focused on a gui element

I want to make a simple change at the cursor just for some “old” vibes but as soon as the mouse is focusing at a gui element (for example a TextButton) it starts to revert back to its original Icon. Even tho’ the script at the bottom looks very small and looks I haven’t tried anything, I used different things like the UserInputService, although didn’t work. I tried to look in the devforums but I didn’t find any solution.
Code (in StarterGui.MouseIcon)

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

mouse.Icon = "rbxassetid://12323309516"

I appreciate any help!

This is what happens:

4 Likes

Is it in a local script? If it isn’t it wont work.

1 Like

It’s a local script, else I wouldn’t have gotten the local player

1 Like

so, I guess every time the cursor over the GUI, the icon changes?
have you tried something like this?

local button = script.Parent -- Assuming the script is a child of the button

local normalCursor = 1 -- Replace with the cursor ID you want to use normally
local customCursor = 2 -- Replace with the cursor ID you want to use when hovering the button

button.MouseEnter:Connect(function()
    -- Change cursor to the custom cursor icon
    game:GetService("StarterGui"):SetCore("MouseIcon", customCursor)
end)

button.MouseLeave:Connect(function()
    -- Change cursor back to the normal cursor icon
    game:GetService("StarterGui"):SetCore("MouseIcon", normalCursor)
end)

2 Likes

It’s telling me this:
SetCore: MouseIcon has not been registered by the CoreScripts

1 Like

This might work but idk. Change game:getservice parts to mouse.mouceicon like u did in the start
edit: also forgot to mention but since your using the new script that “i3_6Core” has provided you will have to get the local players mouse again

1 Like

Unfortunately, button input will forcefully override the cursor’s icon, and there isn’t any trivial way to fix this. You could try creating a custom icon image that displays on top of everything at the cursor’s position, and changes its cursor icon on state change.

1 Like

One way to do this is disabling the normal icon and replacing with a imagelabel like this:
image

local UIS = game:GetService("UserInputService")

UIS.MouseIconEnabled = false -- disables mouse icon

local NewMouse = Instance.new("ImageLabel",script.Parent) -- creates imagelabel which acts as your mouse
NewMouse.BackgroundTransparency = 1
NewMouse.Size = UDim2.new(0,75,0,75)
NewMouse.Image = "rbxassetid://12323309516"

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Move:Connect(function() -- makes ur new mouse follow ur actual mouse
	NewMouse.Position = UDim2.new(0,Mouse.X-40,0,Mouse.Y-40)
end)

i put the one u wanted and fixed the offsets so u dont need to edit this

6 Likes

actually i dont know how that 75,75 size and 40,40 offset looks for you so if its bad then change

1 Like

I saw that Jim’s Computer did it, so I think it must be possible

1 Like

This disabled the Mouse from appearing.

1 Like

did u put the localscript inside a screengui like in the image i send?

1 Like

Oh I am so sorry! I overlooked the screenGui and it works perfectly fine now! I thank you very much and I will remember this from now on. Have a great day and a great day to the ones who also were so kind to help me!

3 Likes

ok good to hear, good luck in your game

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.