Hey, I’m trying to make a cursor change when I click on a part.
Basically, what I want the script to do is change the cursor from the cursor in the first image to the cursor in the second image when it is clicked, then back to the cursor I had before after 0.75 seconds.


The script I made is not erroring at all, just not changing the cursor when clicked.
Here's the script. It goes inside a Part.

-- The button
local button = script.Parent
-- Cursor asset IDs
local Cidle = "9046730465"
local Cactive = "9800994038"
-- Make a clickdetector
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = button
ClickDetector.MaxActivationDistance = 16
ClickDetector.CursorIcon = "rbxassetid://"..Cidle
-- Change the cursor
ClickDetector.MouseClick:Connect(function()
ClickDetector.CursorIcon = "rbxassetid://"..Cactive
wait(.75)
ClickDetector.CursorIcon = "rbxassetid://"..Cidle
end)
2 Likes
If you want to change the mouse icon for the playet that clicked, then you have to do it from a LocalScript.
From a LocalScript get the players mouse, and assign the mouse icon as needed
Am I able to use the same script as I am using now to do this, or will I have to change it?
1 Like
From the DevHub as an example:
-- From a LocalScript:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = Player:GetMouse()
-- Setting the mouse icon
mouse.Icon = "rbxasset://SystemCursors/Wait"
Can you link the page this is from?
Stupid question; where does the localscript go? It’s not working in the part and it’s not giving me an error anywhere
1 Like
Yeah, LocalScripts don’t work in the workspace. Maybe try moving it to the StraterGui and changing the values accordingly?
Put this in StarterGui as a LocalScript:
-- Get player's cursor
local mouse = game.Players.LocalPlayer:GetMouse()
-- The button
local button = workspace.Part
-- Cursor asset IDs
local Cidle = "9046730465"
local Cactive = "9800994038"
-- Make a clickdetector
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = button
ClickDetector.MaxActivationDistance = 16
mouse.Icon = "rbxassetid://"..Cidle
-- Change the cursor
ClickDetector.MouseClick:Connect(function()
mouse.Icon = "rbxassetid://"..Cactive
wait(.75)
mouse.Icon = "rbxassetid://"..Cidle
end)
1 Like
Thanks, It works as intended now!
You’re welcome! Have fun building!
1 Like