#How do I adjust the clicking mouse

1 messages · Page 1 of 1 (latest)

placid anchor
#

I have this script that changes the mouse, no biggy, but I want to change that default clicking mouse whenever it hoves over something clickable.

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local defaultIcon = "http://www.roblox.com/asset/?id=14891607998"
local clickIcon = "http://www.roblox.com/asset/?id=17787998274"

mouse.Icon = defaultIcon

game:GetService("RunService").RenderStepped:Connect(function()
local target = mouse.Target
if target and target:FindFirstChildOfClass("ClickDetector") then
mouse.Icon = clickIcon
else
mouse.Icon = defaultIcon
end
end)

#

clickIcon being the clicking mouse thing, but it wont change it, and no output syntax

merry creek
#

Add a print statement

#

Or 2

placid anchor
#

k

merry creek
#

Try to print target

#

Stuff like that

placid anchor
#

I changed it

#

and you were right

#

I got "nil" for target

#

game:GetService("RunService").RenderStepped:Connect(function()
local target = mouse.Target
print(target)
if target and target:FindFirstChildOfClass("ClickDetector") then
mouse.Icon = clickIcon
print("Changed into ClickIcon")
else
mouse.Icon = defaultIcon
end
end)

#

But how would I fix this? I'm trying to change the hover mouse for both TextButton and parts that have a clickdetector

placid anchor
robust shadowBOT
#

studio** You are now Level 2! **studio

merry creek
#

Idk i did not expect it to be nil, like is it nil when hovering over a part?

placid anchor
#

it says NIL

merry creek
#

Oh

#

Well target is the part in 3D space that the mouse is hovering over

placid anchor
#

ah

#

then what would be for GUIs?

merry creek
#

I don’t think there is a property for gui buttons like that

placid anchor
#

Then I wont be able to adjust the clicking icon?

#

for GUIs?

merry creek
#

Honestly, i don’t know

Best advice: ask chatgpt how to do it, without code, and do it yourself like it said.

placid anchor
#

I never used chatgpt for coding help before, I'll try it out

placid anchor
young acorn
#

i don't remember but it's something like uis.guiobject

placid anchor
#

I'll look in some forums for that

#

thank you

young acorn
#

i remember finding it after learning about mouse.hoverenter/exit is glitchy

placid anchor
#

GuiObject is an abstract class (much like BasePart) for a 2D user interface object. It defines all the properties relating to the display of a graphical user interface (GUI) object such as Size and Position. It also has some useful read‑only properties like AbsolutePosition, AbsoluteSize, and AbsoluteRotation.

To manipulate the layout of GUI objects in special ways, you can use a layout structure such as list/flex or grid, and you can style them beyond their core properties through appearance modifiers.

Although it's possible to detect mouse button events on any GUI object using InputBegan and InputEnded, only ImageButton and TextButton have convenient dedicated events such as Activated to detect click/press.

young acorn
placid anchor
#

I'll try to implement this one

lunar ermine
placid anchor
#

it isnt clickdetector, here let me showo you

#

That p[lay button has a textbutton

young acorn
#

i could've sworn there was one that only gives you the top gui object but i may be mistaken on that

#

you'll also need to cover a bunch of different hovering contexts like showing text cursor when hovering a textbox

#

quite a bit of work to make this work 👍

placid anchor
#

eh, I got whole summer break; if it takes too long I'll work on it later

#

I have to finish my firearm logic anyway

young acorn
#

or just only do textbuttons/imagebuttons, and click detectors ;p

placid anchor
#

Alright, thank you for the help, I'll @ you if I need anything else

placid anchor
#

Okay so I tried to use 2 ways of changing, first was to change the actual mouse icon to one icon, then make a script to disable mouse whenever it goes over a clickable gui, and change it into a image. It works partially, and partially being that the image wont show up in the loading screen. Here is the script I tried doing, (image has zindex 1000 and order 1000).

local button = game.StarterGui.LoadingScreen.Frame:WaitForChild("TextButton")
local mouse = game.Players.LocalPlayer:GetMouse()
local icon = script.Parent

button.MouseEnter:connect(function(x, y)
    game:GetService("UserInputService").MouseIconEnabled = false
    icon.Visible = true
end)

button.MouseLeave:connect(function()
    game:GetService("UserInputService").MouseIconEnabled = true
    icon.Visible = false
end)

game:GetService("RunService").RenderStepped:connect(function()
    icon.Position = UDim2.new(0, mouse.X - 76, 0, mouse.Y - 76)
end)
#

however if I adjust the script like this

#
local button = script.Parent.Parent.TestButton
local mouse = game.Players.LocalPlayer:GetMouse()
local icon = script.Parent

button.MouseEnter:connect(function(x, y)
    game:GetService("UserInputService").MouseIconEnabled = false
    icon.Visible = true
end)

button.MouseLeave:connect(function()
    game:GetService("UserInputService").MouseIconEnabled = true
    icon.Visible = false
end)

game:GetService("RunService").RenderStepped:connect(function()
    icon.Position = UDim2.new(0, mouse.X - 76, 0, mouse.Y - 76)
end)
#

Then it will work

#

but only for that button

#

that button also has order 1000 and zindex 1000

#

this is the script for the icon changer

#
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local defaultIcon = "http://www.roblox.com/asset/?id=14891607998"

mouse.Icon = defaultIcon
#

@young acorn

#

If there is any shortcut you can think of please tell me

young acorn
#

use replicatedfirst for loadingscreens, you dont need waitforchild for stuff in replicatedfirst