So I have a userinputservice going on in my script
and I tried to set a
InputObject:GetPropertyChangedSignal("Position")
Apparently this works perfectly fine on Mobile
But when it comes to desktop it fires once which is when the Input has ended
Does anyone know why this is?
Heres my code
ImageButton.InputBegan:Connect(function(InputObject) if InputObject.UserInputType == Enum.UserInputType.MouseButton1 or InputObject.UserInputType == Enum.UserInputType.Touch then InputObject:GetPropertyChangedSignal("Position"):Connect(function() print('Mouse has moved') end) end end)
To be honest this code does work on Desktop too but the printing seems to stack meaning the events are stacking
which is a memory leak?
Anyone know whats going on?
what you have to do is disconnect the events
local Connection = nil ImageButton.InputBegan:Connect(function(InputObject) if InputObject.UserInputType == Enum.UserInputType.MouseButton1 or InputObject.UserInputType == Enum.UserInputType.Touch then Connection = InputObject:GetPropertyChangedSignal("Position"):Connect(function() print("MouseMoved") end) end end) ImageButton.InputEnded:Connect(function() if Connection then Connection:Disconnect() Connection = nil end end)