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:

3 Likes

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

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

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)

1 Like

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

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

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.

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

4 Likes

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

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

This disabled the Mouse from appearing.

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

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!

2 Likes

ok good to hear, good luck in your game

3 Likes

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