How would I change the default Roblox cursor to my own image?
local Players = game:GetService("Players")
local mouse = Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset?id=replace with the content id of you're image"
Try this:
--//Services
local Players = game:GetService("Players")
--//Variables
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
--//Functions
Mouse.Icon = "rbxasset://yourid"
I suppose you could do this by changing the Icon, which works but isn’t practical because it will change back when you hover a button or something. Instead turn off the Mouse:
UserInputService.MouseIconEnabled = false
Then you could make an image follow the mouse:
mouse.Move:Connect(function()
Image.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end)
It may not be centered, to do that change the anchor point to 0.5,0.5
Make sure the Zindex is higher than all other UI’s so the mouse doesn’t go under.
Due to security reasons the image will not go above CoreUi.
Full script:
local inputServ = game:GetService("UserInputService");
local players = game:GetService("Players");
local player = players.LocalPlayer; --player
local mouse = player:GetMouse(); -- mouse
local Image = -- put directory here
inputServ.MouseIconEnabled = false; -- disables the mouse icon (makes the mouse 'invisible')
mouse.Move:Connect(function() -- fires when the mouse moves
Image.Position = UDim2.new(mouse.X, 0, mouse.Y, 0); -- Changes image position to the mouse position
end)
Thanks it worked, exactly what I was looking for, but how would I make it work on buttons?
Do you mean CoreGui or just buttons you made?
I mean, when I hover over a text button it will change to a different cursor for example.
You’d change the ‘Image’ property of the ImageLabel which is emulating the client’s cursor.
Image.Image = "rbxassetid://0" --Replace '0' with the desired image's ID.
Oh I see, try this instead
local inputServ = game:GetService("UserInputService");
local players = game:GetService("Players");
local player = Players.LocalPlayer; --player
local mouse = player:GetMouse(); -- mouse
local Image = -- put directory here
mouse.Move:Connect(function() -- fires when the mouse move
inputServ.MouseIconEnabled = false; -- disables the mouse icon (makes the mouse 'invisible')
Image.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y); -- Changes image position to the mouse position
end