How can I make my own Joystick for a mobile game

Hi, I am trying to make some controls for a rocket that requires 2 JoySticks 1 for steerig and another for throttle, I tried using TouchPan cause when I was using the UserInputService.TouchMoved it trigger the TouchedEnded when I let go of one of the joySticks and that made it stop working this is the code am using to make my imageLabel behave like a JoyStick but it`s not working correctly. Cause it moves it way out of the Frame

local function onThrottleTouchPan(touchPositions, totalTranslation, velocity, state)
	if state == Enum.UserInputState.Begin and not throttleDragging then
		print("Input Began")
		throttleDragging = true
		Throttle_Frame.BackgroundTransparency = 0.8
		--Throttle_Button.Visble = true
	elseif state == Enum.UserInputState.Change then
		local pos = touchPositions[1]
		print(pos)
		
		if (pos.X > Throttle_GuiPos.X) and (pos.X < Throttle_GuiPos.X + Throttle_GuiSize.X) and (pos.Y > Throttle_GuiPos.Y) and (pos.Y < Throttle_GuiPos.Y + Throttle_GuiSize.Y) then
			local startPos = Throttle_Button.Position
			local position = UDim2.new(startPos.X.Scale, startPos.X.Offset, startPos.Y.Scale, startPos.Y.Offset + totalTranslation.Y)
			Throttle_Button.Position = position
			print("Pos", position)
		end
		--tweenButton(Throttle_Button, position, dragSpeed)
		print(touchPositions)
		print(totalTranslation)
		print(velocity)
		
	elseif state == Enum.UserInputState.End and throttleDragging then
		print("input ended")
		tweenButton(Throttle_Button, THROTTLE_ORIGINAL_POS, dragReturnSpeed)
		RocketControl:FireServer("SpeedUp", false)
		RocketControl:FireServer("SlowDown", false)
		throttleDragging = false
		Throttle_Frame.BackgroundTransparency = 1
	end
end
2 Likes

Try Changing the the topic to scripting support and not creations feedback, and you need to split the screen in to halves then figured out when the player lets go in one half in the screen.

1 Like

im pretty sure this is meant to go in #help-and-feedback:scripting-support, but besides that,

are these why its not working? im still really new to scripting so i have no idea lol, but they are really long so i thought maybe something broke there?

Yeah I actually tried that and it didn’t work, I actually found that one solution is to make a different object for every input, so when one of them triggers the input ended you know which one it is.

No actually the code was working right but when I let go of one of my firgers it trigger the input ended and it was like if I had let go of both fingers at the same time.