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

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

function DynamicThumbstick:EnableAutoJump(enable)
	local humanoid = Players.LocalPlayer.Character and Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		if enable then
			self.shouldRevertAutoJumpOnDisable = (humanoid.AutoJumpEnabled == false) and (Players.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 Players.LocalPlayer.Character then
			self:OnCharacterAdded(Players.LocalPlayer.Character)
		else
			Players.LocalPlayer.CharacterAdded:Connect(function(char)
				self:OnCharacterAdded(char)
			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)

	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)
		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)
	end
end
