Kind of, I’m using this for cursor changes depending on who (or what) the mouse is pointed at; primarily allies/enemies or neutral things
Someone told me I can try putting a ClickDetector inside every player and track their .MouseHoverEnter or to just modify their MouseIcon property. It seems feasible, and probably better than a loop running every frame…
The Mouse object in Roblox doesn’t work like other objects where you can use GetPropertyChangedSignal to detect when a property changes. The reason your code doesn’t fire the event for Mouse.Target is because the Mouse object is because it doesn’t have property change signals in the usual sense.
The Mouse.Target property is constantly being updated by Roblox as you move your mouse around, but it doesn’t trigger any events when it changes. So even if you try to connect Mouse:GetPropertyChangedSignal("Target"), it’s simply not designed that way.
If you want to track when the target changes, the most straightforward way is to use a loop. I know loops aren’t ideal, but here’s a trick: you can use a loop that runs every frame to check if the target has changed, and only do something if it actually has. For example:
local RunService = game:GetService("RunService")
local LocalPlayer = game:GetService("Players").LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local lastTarget = nil
RunService.RenderStepped:Connect(function()
if Mouse.Target ~= lastTarget then
lastTarget = Mouse.Target
print("New target:", lastTarget)
end
end)
Every time you try and fetch a property, you are actually calling a function to find it’s value. Target happens to be a property that isn’t fetched by any other part of the engine, thus it’s value is never computed unless you call it, which is why your property changed signals do not get fired.