I want to reduce my use of loops in my scripts. I am working on a radar gun for my game, and instead of running a constant loop to check the mouse.Target, I want to use mouse:GetPropertyChangedSignal("Target"). It hasn’t been working, so I am not sure if I am doing something wrong or if it just doesn’t work. I went into the object browser and the function is listed under mouse, so I am unsure.
Any help you can give would be greatly appreciated.
Clone = script.Radar:Clone()
Clone.Parent=player.PlayerGui
mouse:GetPropertyChangedSignal("Target"):Connect(function()
print'target'
local target = mouse.Target
if target~=nil then
local rawSpeed = math.floor(target.Velocity.Magnitude)
if rawSpeed>0 then
local speed = rawSpeed*ac6MPHRate
Clone.Speed.Text = "Speed Clocked:\n"..speed
end
end
end)
I decided I am just going to use RunService.RenderStepped. Seems to be the only option. I am not going to use mouse.Move though because if you keep your mouse stationary, and the target changes, it will not fire. Thank you guys for your help :))
that :GetPropertyChangedSignal doesn’t fire? Not a bug. I suspect that would fire basically the same as RenderStepped, it could be just that also they forgot. there is the mouse.Move like they mentioned above though. Not sure why you didn’t use that, it’s basically what you mentioned.