function DynamicThumbstick.GetIsJumping(G)local a=G.isJumping G.isJumping=false return a end function DynamicThumbstick.EnableAutoJump(a,G)if FFlagUserDTDoesNotForceAutoJump then return end local t=LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if t then if G then a.shouldRevertAutoJumpOnDisable=t.AutoJumpEnabled==false and LocalPlayer.DevTouchMovementMode==Enum.DevTouchMovementMode.UserChoice t.AutoJumpEnabled=true elseif a.shouldRevertAutoJumpOnDisable then t.AutoJumpEnabled=false end end end function DynamicThumbstick.Enable(t,G,a)if G==nil then return false end G=G and true or false if t.enabled==G then return true end if G then if not t.thumbstickFrame then t:Create(a)end t:BindContextActions()if not FFlagUserDTDoesNotTrackTools then if LocalPlayer.Character then t:OnCharacterAdded(LocalPlayer.Character)else LocalPlayer.CharacterAdded:Connect(function(G)t:OnCharacterAdded(G)end)end end else ContextActionService:UnbindAction(DYNAMIC_THUMBSTICK_ACTION_NAME)t:OnInputEnded()end t.enabled=G t.thumbstickFrame.Visible=G end function DynamicThumbstick.OnCharacterAdded(a,G)assert(not FFlagUserDTDoesNotTrackTools)for G,t in ipairs(G:GetChildren())do if t:IsA("\084\111\111\108")then a.toolEquipped=t end end G.ChildAdded:Connect(function(G)if G:IsA("\084\111\111\108")then a.toolEquipped=G elseif G:IsA("\072\117\109\097\110\111\105\100")then a:EnableAutoJump(true)end end)G.ChildRemoved:Connect(function(G)if G==a.toolEquipped then a.toolEquipped=nil end end)a.humanoid=G:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if a.humanoid then a:EnableAutoJump(true)end end

function DynamicThumbstick:GetIsJumping()
	local wasJumping = self.isJumping
	self.isJumping = false
	return wasJumping
end

function DynamicThumbstick:EnableAutoJump(enable) -- Remove on FFlagUserDTDoesNotForceAutoJump
	if FFlagUserDTDoesNotForceAutoJump then
		return
	end
	local humanoid = LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		if enable then
			self.shouldRevertAutoJumpOnDisable = (humanoid.AutoJumpEnabled == false) and (LocalPlayer.DevTouchMovementMode == Enum.DevTouchMovementMode.UserChoice)
			humanoid.AutoJumpEnabled = true
		elseif self.shouldRevertAutoJumpOnDisable then
			humanoid.AutoJumpEnabled = false
		end
	end
end

function DynamicThumbstick:Enable(enable, uiParentFrame)
	if enable == nil then return false end			-- If nil, return false (invalid argument)
	enable = enable and true or false				-- Force anything non-nil to boolean before comparison
	if self.enabled == enable then return true end	-- If no state change, return true indicating already in requested state

	if enable then
		-- Enable
		if not self.thumbstickFrame then
			self:Create(uiParentFrame)
		end

		self:BindContextActions()

		if not FFlagUserDTDoesNotTrackTools then
			if LocalPlayer.Character then
				self:OnCharacterAdded(LocalPlayer.Character)
			else
				LocalPlayer.CharacterAdded:Connect(function(char)
					self:OnCharacterAdded(char)
				end)
			end
		end
	else
		ContextActionService:UnbindAction(DYNAMIC_THUMBSTICK_ACTION_NAME)
		-- Disable
		self:OnInputEnded() -- Cleanup
	end

	self.enabled = enable
	self.thumbstickFrame.Visible = enable
end

function DynamicThumbstick:OnCharacterAdded(char) -- Remove on FFlagUserDTDoesNotTrackTools
	assert(not FFlagUserDTDoesNotTrackTools)

	for _, child in ipairs(char:GetChildren()) do
		if child:IsA("Tool") then
			self.toolEquipped = child
		end
	end

	char.ChildAdded:Connect(function(child)
		if child:IsA("Tool") then
			self.toolEquipped = child
		elseif child:IsA("Humanoid") then
			self:EnableAutoJump(true) -- Remove on FFlagUserDTDoesNotForceAutoJump
		end
	end)
	char.ChildRemoved:Connect(function(child)
		if child == self.toolEquipped then
			self.toolEquipped = nil
		end
	end)

	self.humanoid = char:FindFirstChildOfClass("Humanoid")
	if self.humanoid then
		self:EnableAutoJump(true) -- Remove on FFlagUserDTDoesNotForceAutoJump
	end
end
