I made this script earlier to get around the stupid Roblox incapibility, which is to not have a Custom Mouse HoverOver image. Really annoying. If any Roblox staff see this, please add that!
But anyways, my script isn’t working, with no error.
What’s wrong?
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
while wait (0.1) do
local t = script.Parent:GetDescendants()
for _, instance in pairs(t) do
if instance:IsA("ImageButton") then
instance.MouseEnter:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027845989"
end)
instance.MouseLeave:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
end)
elseif instance:IsA("ImageButton") then
instance.MouseEnter:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027845989"
end)
instance.MouseLeave:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
end)
end
end
end
What’s wrong there? Thanks!
Video:
(pressed multiple buttons to prove it wan’t defective on only one)
No errors
Anyways, that’s first because those buttons are TextButtons, not ImageButtons.
Second of all, having a loop that makes a Connection with every Image button in the script’s Parent’s descendants 10 times a second is not a good idea.
You should wait for the buttons you want connected using WaitForChild, then connect them.
Example:
local Buttons= {
[path using WaitForChild],
[path using WaitForChild],
--etc
}
for _,instance in pairs(Buttons) do
instance.MouseEnter:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027845989"
end)
instance.MouseLeave:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
end)
end
Do you have an example with your second suggestion?
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
while wait (0.1) do
local t = script.Parent:GetDescendants()
for _, instance in pairs(t) do
if instance:IsA("ImageButton") then
instance.MouseEnter:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027845989"
end)
instance.MouseLeave:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
end)
elseif instance:IsA("TextButton") then
instance.MouseEnter:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027845989"
end)
instance.MouseLeave:Connect(function()
mouse.Icon = "http://www.roblox.com/asset/?id=7027810711"
end)
end
end
end
Take the mouse images, put them in a decal, wait a few seconds, the image should be a few numbers different, paste the new number where you had the old ones. I’m 99.9% sure theres a better method for that though, just never got around to figuring it out.
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "rbxassetid://7027810711"
local t = script.Parent:GetDescendants()
for _, instance in pairs(t) do
if instance:IsA("ImageButton") then
instance.MouseEnter:Connect(function()
wait()
mouse.Icon = "rbxassetid://7027845989"
end)
instance.MouseLeave:Connect(function()
wait()
mouse.Icon = "rbxassetid://7027810711"
end)
elseif instance:IsA("TextButton") then
instance.MouseEnter:Connect(function()
wait(0.1)
mouse.Icon = "rbxassetid://7027845989"
end)
instance.MouseLeave:Connect(function()
wait(0.1)
mouse.Icon = "rbxassetid://7027810711"
end)
end
end