I want to know how to make a script that can change ClickDetector cursor icon the way that it will be working on every ClickDetector that is located in workspace. I already tried searching and i could make it work only on one brick. (Excuse my bad english please)
local clickDetector = game.Workspace.Part.ClickDetector local icon = "rbxassetid://878096274" local icon2 = "rbxassetid://878076293" clickDetector.MouseHoverEnter:connect(function(player) local mouse = player:GetMouse() mouse.Icon = icon end) clickDetector.MouseHoverLeave:connect(function(player) local mouse = player:GetMouse() mouse.Icon = icon2 end)
This is the script that i've been using.
Hello Alexeeii,
The function that will be shown below searches everywhere in an entity, including its children, and it's children's children, and so on, for example, workspace. I like to think of it as a "deep search".
function Search(ItemToSearch) for i, v in pairs(ItemToSearch:GetChildren()) do if v:IsA("Part") then v.BrickColor = "Really red" end Search(v) --This repeats the search on the children of the children so it allows one to infinitely search through children of children, and their children, and their children, and so on. end end) --This would make every part that exists somewhere inside ItemToSearch turn red.
Then you'd use the function of whatever you'd like to "deep search". For example,
Search(workspace) --This would make all parts in the workspace red, no matter where they are in the workspace.
In your case, you'd like to do things with all ClickDetectors in the workspace. So, your code would look something like this:
local icon = "rbxassetid://878096274" local icon2 = "rbxassetid://878076293" function Search(ItemToSearch) for i, v in pairs(ItemToSearch:GetChildren()) do if v:IsA("ClickDetector") then v.MouseHoverEnter:connect(function(Player) local Mouse = Player:GetMouse() Mouse.Icon = icon end) v.MouseHoverLeave:connect(function(Player) local Mouse = Player:GetMouse() Mouse.Icon = icon2 end) end Search(v) end end Search(workspace)