function DynamicThumbstick.GetIsJumping(l)local s=l.isJumping l.isJumping=false return s end function DynamicThumbstick.EnableAutoJump(s,l)local L=Players.LocalPlayer.Character and Players.LocalPlayer.Character:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if L then if l then s.shouldRevertAutoJumpOnDisable=L.AutoJumpEnabled==false and Players.LocalPlayer.DevTouchMovementMode==Enum.DevTouchMovementMode.UserChoice L.AutoJumpEnabled=true elseif s.shouldRevertAutoJumpOnDisable then L.AutoJumpEnabled=false end end end function DynamicThumbstick.Enable(L,l,s)if l==nil then return false end l=l and true or false if L.enabled==l then return true end if l then if not L.thumbstickFrame then L:Create(s)end if Players.LocalPlayer.Character then L:OnCharacterAdded(Players.LocalPlayer.Character)else Players.LocalPlayer.CharacterAdded:Connect(function(l)L:OnCharacterAdded(l)end)end else L:OnInputEnded()end L.enabled=l L.thumbstickFrame.Visible=l end function DynamicThumbstick.OnCharacterAdded(s,l)for l,L in ipairs(l:GetChildren())do if L:IsA("\084\111\111\108")then s.toolEquipped=L end end l.ChildAdded:Connect(function(l)if l:IsA("\084\111\111\108")then s.toolEquipped=l elseif l:IsA("\072\117\109\097\110\111\105\100")then s:EnableAutoJump(true)end end)l.ChildRemoved:Connect(function(l)if l==s.toolEquipped then s.toolEquipped=nil end end)s.humanoid=l:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if s.humanoid then s: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

		if Players.LocalPlayer.Character then
			self:OnCharacterAdded(Players.LocalPlayer.Character)
		else
			Players.LocalPlayer.CharacterAdded:Connect(function(char)
				self:OnCharacterAdded(char)
			end)
		end
	else
		-- 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
