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)
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”
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.
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
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)
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.