You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I have a custom joystick with aUIDragDetector
. When the joystick disappears (not destroyed), I want to make the player let go of the drag detector -
What is the issue? Include screenshots / videos if possible!
When the Gui object’sVisible
property is disabled, the player will still be dragging theUIDragDetector
, and it will send any changes in input, which will cause an issue in my game -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried looking for solutions, but I didn’t find anything relevant
I need to be able to hide the joystick due to changes in the state of the game, as the joystick is only meant to appear in certain circumstances
I could just make the UIDragDetector.DragContinue
event stop sending changes in input, but it doesn’t feel like an ideal solution
Here is the aforementioned solution:
dragDetector.DragContinue:Connect(function()
if joystickHandle.Parent.Visible then -- this if statement is what I mean
local joystickX = (joystickHandle.Position.X.Scale - 0.5) * 2
local joystickY = (joystickHandle.Position.Y.Scale - 0.5) * 2
local joystickPosition = Vector2.new(joystickX, -joystickY).Unit
bindableJoystickEvent:Fire(joystickPosition) -- sends info to other LocalScripts
end
end)
The player would still be able to drag the UIDragDetector
, but at least it wont send anything. Is there a better solution?