Hey everyone! So this is sort of a non issue. Its not too “game changing” but I’d like to know how I would make it so when you hover your cursor over a part with a clickdetector inside of it it changes to a different icon when a custom cursor is being used.
This is what I am looking for.
But when a custom cursor is applied…
I’d like to know how to make it so the icon changes like in the first video. I’ve already tried the cursoricon property in the clickdetector but it doesn’t change anything. Is there an easier way to change this instead of using MouseHoverEnter and making a table with all my clickdetectors?
Place a local script into StarterPlayerScripts and paste in this script. I tested, it worked.
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local descendants = workspace:GetDescendants()
for i, descendant in pairs(descendants) do
if descendant:IsA("ClickDetector") then
descendant.MouseHoverEnter:Connect(function()
mouse.Icon = "rbxassetid://6632175405" --Your icon here
end)
descendant.MouseHoverLeave:Connect(function()
mouse.Icon = "rbxasset://textures/Cursors/KeyboardMouse/ArrowFarCursor.png"
end)
end
end
Basically you just getting everything in workspace, and checking if it is clickdetector. And using MouseHoverEnter, MouseHoverLeave to set the icon.
I don’t know if it will lagg with a lot of instances in workspace.
How wouldnt that work using Changed event is much more performance wise than checking in constant loop he even suggested to use Disconnect which is even better for the performance The way you are saying isnt wrong but its really bad for performance
local Game = game
local Workspace = workspace
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Cache = {} --Used to cache connections.
local function OnMouseHoverEnter()
Mouse.Icon = "rbxassetid://0"
end
local function OnMouseHoverLeave()
Mouse.Icon = "rbxassetid://0"
end
local function OnWorkspaceDescendantAdded(Descendant)
if not (Descendant:IsA("ClickDetector")) then return end
Cache[Descendant] = {
Descendant.MouseHoverEnter:Connect(OnMouseHoverEnter),
Descendant.MouseHoverLeave:Connect(OnMouseHoverLeave)
}
end
local function OnWorkspaceDescendantRemoving(Descendant)
if not (Descendant:IsA("ClickDetector")) then return end
for _, Connection in ipairs(Cache[Descendant]) do
Connection:Disconnect()
end
Cache[Descendant] = nil
end
Workspace.DescendantAdded:Connect(OnWorkspaceDescendantAdded)
Workspace.DescendantRemoving:Connect(OnWorkspaceDescendantRemoving)
for _, Descendant in ipairs(Workspace:GetDescendants()) do
OnWorkspaceDescendantAdded(Descendant)
end