I made a script that just changes the Mouse Icon permanently, but it does not change when I hover over a part with a click detector (The Click Detector has a custom Icon, and it doesnt show)
How would I fix this?
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local lastIcon
mouse:GetPropertyChangedSignal("Target"):Connect(function()
if mouse.Target and mouse.Target:IsA("ClickDetector") then
lastIcon = mouse.Icon
mouse.Icon = nil
else
mouse.Icon = lastIcon
end
end)
what would I replace nil with? would it be the id and only the id? or would it be rbxassetid://?
Replace it with mouse.Target.CursorIcon
would this script be a new script or would I put it into the script with the mouse icon?
Also, where would this script go?
Put it in a local script in starter player scripts.
It did not work…
Here is my cursor script if that would help
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Setting the mouse icon
mouse.Icon = "rbxassetid://11761881620"
and here is your script:
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local lastIcon
mouse:GetPropertyChangedSignal("Target"):Connect(function()
if mouse.Target and mouse.Target:IsA("ClickDetector") then
lastIcon = mouse.Icon
mouse.Icon = mouse.Target.CursorIcon
else
mouse.Icon = lastIcon
end
end)
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local lastIcon
mouse:GetPropertyChangedSignal("Target"):Connect(function()
--[[
I don't believe Mouse.Target can be a ClickDetector itself, and only parts can.
So I search through for a ClickDetector as a child of Mouse.Target.
(I may be wrong in doing this.)
]]
if mouse.Target and mouse.Target:FindFirstChildWhichIsA("ClickDetector") then
lastIcon = mouse.Icon
mouse.Icon = mouse.Target:FindFirstChildWhichIsA("ClickDetector").CursorIcon
else
mouse.Icon = lastIcon
end
end)
I apologize if this code does not work either, I may not have found all of the errors.
It unfortunately does not work, I’m not sure why.
Hmmmm. Does it print out any errors?
Is the ClickDetector’s CursorIcon property set?
How does the cursor behave when hovering over the ClickDetector?
Try this code and tell me what it prints, if anything.
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local lastIcon
mouse:GetPropertyChangedSignal("Target"):Connect(function()
--[[
I don't believe Mouse.Target can be a ClickDetector itself, and only parts can.
So I search through for a ClickDetector as a child of Mouse.Target.
(I may be wrong in doing this.)
]]
if mouse.Target and mouse.Target:FindFirstChildWhichIsA("ClickDetector") then
lastIcon = mouse.Icon
mouse.Icon = mouse.Target:FindFirstChildWhichIsA("ClickDetector").CursorIcon
print(tostring(mouse.Target:FindFirstChildWhichIsA("ClickDetector").CursorIcon)) -- Added this
else
mouse.Icon = lastIcon
end
end)
There are no errors being printed
It is already detecting when the mouse target property changes. The code will trigger every time the mouse starts hovering over a different part. In this case, heartbeat would be unnecessary performance loss.
Try the code I provided and see if it prints anything. If so, tell me what it prints.
does the code go inside of starterplayerscripts? nothing is showing up.
Where is the script currently located?
it is in starterplayerscripts.
If you put a print(“Hello, world!”) at the beginning of the script, will that print out?
Note: Put the print outside of the connection
The Prompt does get printed in output, so I dont know why this wouldnt be working.