I’m extremely new to scripting, and I’m having trouble with my custom mouse icon. The first script I had worked fine unless I hovered over a ImageButton, in which it would revert back to the original mouse icon. I had a simple local script to change the mouse icon located in StarterPlayerScripts as seen here.
wait(.5)
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "rbxassetid://6037323517"
Recently after finding no solution, I tried working with ClickDetector by grouping all the assets I wanted the icon to draw over into a folder and calling them in a table with no luck still. Ive been at this all day and some help would be appreciated .
Here’s a ss of the place, and the code I’m currently working with.
local mouseIcon = "rbxassetid://6037323517" --mouse icon local clickIcon = "rbxassetid://6037323517" --click detector icon
local clickDetector = Instance.new("ClickDetector")
local mouse = game.Players.LocalPlayer:GetMouse()
local Buttons = game.StarterGui.OpeningSequence.Buttons
You have to get the Gui from PlayerGui not StarterGui, since the Gui’s from StarterGui go in PlayerGui. And is there a Buttons folder in your workspace?
Yeah as mentioned by @ZeroIQ_Scripter there are a lot of weird problems. One is using click detectors in order to use its MouseHover events in order to change the mouse. Great idea in theory but sadly click detectors only work on 3d objects:
when parented to BasePart , Model or Folder objects
Now onto the problem, for GUI Buttons sadly the only solution I could find is to do this weird workaround by creating an image label and having it replace the mouse like in the post below manually using the mouse enter and mouse left events:
At the start of every game, the StarterGui folder is duplicated to the PlayerGui folder which can be located in each of the players. Therefore, I’d recommend changing this line of code to this:
local Buttons = script.Parent.Buttons
Furthermore, ClickDetectors aren’t used in GUIs, and instead you would have to use a text/image button and reference it from there.
I’m not sure if you have even a Buttons folder in your workspace, either way, that line of code wouldn’t work because you’re not referencing the variable’s property or location directly, and you would have to clone it for it to work for every child of the parenting folder. Try this:
for i,v in pairs(workspace.Buttons:GetChildren()) do
local clickDetectorClone = clickDetector:Clone()
local clickDetectorClone.Parent = v
end
Yea I read through Click Detector wiki page and assumed it wouldnt work, I also saw his post but was hoping there was a better way to go about it. Thanks man.
EDIT: I got this to work from the post you sent, one small change fixed it though.
You have to change the true, to false for MouseIconEnabled and false, to true for icon.Visable to get the icon to stay connected to your mouse when you leave the GUI.