Hello, I had changed the base cursor successfully via this local script:
local m = game.Players.LocalPlayer:GetMouse()
m.Icon = "http://www.roblox.com/asset/?id=6872579222"
But since then, when I hover my cursor over a click detector, the cursor does not change.
I found this script to change the cursors except that it changes the cursor of a single click detector that I mention in the script beforehand:
local mouseIcon = "rbxassetid://6872579222" --mouse icon
local clickIcon = "rbxassetid://10392882845" --click detector icon
local clickDetector = workspace.PartClicDetector.ClickDetector --click detector reference
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = mouseIcon
clickDetector.MouseHoverEnter:Connect(function()
mouse.Icon = clickIcon
end)
clickDetector.MouseHoverLeave:Connect(function()
mouse.Icon = mouseIcon
end)
So, how to change this line so that it changes the cursor for all clickdetectors? :
local clickDetector = workspace.PartCliclDetector.ClickDetector
Why not just add that to all the click detectors and be done with it. You could aim all that at a StingValue and load that from every script. Other than that do a search via folder or tag and update them one at a time, or make a module. I like the one you have now.
Create a Script and put it inside ServerScriptService
(Note that this may not be the best way)
ServerScriptService
for _,i in pairs(workspace:GetDescendants()) do -- Gets Every single Item in the workspace
if i:IsA("ClickDetector") then -- Checks if the item is a ClickDetector
i.MouseHoverEnter:Connect(function(p)
p:GetMouse().Icon = clickIcon
end)
i.MouseHoverLeave:Connect(function(p)
p:GetMouse().Icon = mouseIcon
end)
end
end
B
Create a RemoteEvent or RemoteFunction to Apply the Mouse Icon
local Event = game.ReplicatedStorage.MouseEvent
clickDetector.MouseHoverEnter:Connect(function()
Event:FireServer(mouse.Icon, Your Image)
end)
clickDetector.MouseHoverLeave:Connect(function()
Event:FireServer(mouse.Icon, Your Image)
end)
C
Put a LocalScript inside StarterCharacterScripts
(Similar to A)
for i,v in pairs(workspace:GetDescendants()) do
if v:IsA("ClickDetector") then
print(i, v)
v.MouseHoverEnter:Connect(function(p)
print("yemen") -- yeah man, its there
end)
v.MouseHoverLeave:Connect(function(p)
print("oman") -- Oh man, its gone
end)
end
end