Mouse.Icon Issue

I seem to be having an issue with mouse.Icon, any help would be greatly appricated, as its not changing the mouse Icon to anything and it simply goes blank/transparent i think.

local UserInputService = game:GetService("UserInputService")

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

-- Configuration


local isMouseLocked = false


-- Function to lock/unlock mouse
local function toggleMouseLock()
	if isMouseLocked == false then
		isMouseLocked = true
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		mouse.Icon = "rbxasset://SystemCursors/Cross	"
		
	else
		isMouseLocked = false
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		mouse.Icon = "rbxasset://SystemCursors/Arrow	"
		
	end
	print("isMouseLocked:", isMouseLocked)
end

-- Toggle mouse lock on right-click
UserInputService.InputBegan:Connect(function(input, isProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		toggleMouseLock()
	end
end)
1 Like

You didnt put the id you put something else

1 Like

Don’t forget that there is also built in roblox assets.

1 Like

I did check that I can do this as it does say here

Ehh?? What is that space in the end of the ID? "rbxasset://SystemCursors/Arrow " - wrong, just remove the space at the end of the string! Like that - “rbxasset://SystemCursors/Arrow”

I still get the same result, i’ve even tried doing it outside of the function however it just turns the cursor invisible.

Use UIS to change the mouse icon. The mouse object is pretty unoptimized and the documentation says to not use it. Basically 2x slower to use Mouse.hit instead of raycasting yourself.

UIS.MouseIcon = "rbxasset://SystemCursors/Arrow"

Also I don’t know if you’re allowed to use the system cursors. Edit: I just looked around and everything says you’re only allowed to use them in plugins @Bear23913

That would explain a few things, thank you!

Thats because those assets do not exist. Theres the fixed version using proper assets:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local mouse = player:GetMouse()

-- Configuration
local isMouseLocked = false

-- Function to lock/unlock mouse
local function toggleMouseLock()
	if isMouseLocked == false then
		isMouseLocked = true
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		mouse.Icon = "rbxasset://textures/Cursors/CrossMouseIcon.png"
	else
		isMouseLocked = false
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		mouse.Icon = "rbxasset://textures/Cursors/KeyboardMouse/ArrowFarCursor.png"

	end
	print("isMouseLocked:", isMouseLocked)
end

-- Toggle mouse lock on right-click
UserInputService.InputBegan:Connect(function(input, isProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		toggleMouseLock()
	end
end)
1 Like

Thank you if you wouldnt mind sending me the resource so i can referance that for icons in future if you wouldnt mind?

I just go into the files and look through the textures folder lolz

Edit:

To find the roblox textures folder you need to go to:
(your username)>AppData>Local>Roblox>Versions>(The client version)>content>textures
Im assuming that you’re using Windows. And to see that folder you need to enable viewing hidden folders.

1 Like

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