local function C()JumpButton.Visible=false OnInputEnded()end local function J()if Humanoid and ExternallyEnabled then if ExternallyEnabled then if Humanoid.JumpPower>0 then JumpButton.Visible=true end end end end local function t()if JumpPower>0 and JumpStateEnabled then J()else C()end end local function O(C)if C=="\074\117\109\112\080\111\119\101\114"then JumpPower=Humanoid.JumpPower t()elseif C=="\080\097\114\101\110\116"then if not Humanoid.Parent then HumChangeConnection:disconnect()end end end local function m(C,J)if C==Enum.HumanoidStateType.Jumping then JumpStateEnabled=J t()end end local function h(C)if HumChangeConnection then HumChangeConnection:disconnect()end Humanoid=nil repeat Humanoid=MasterControl:GetHumanoid()task.wait()until Humanoid and Humanoid.Parent==C HumChangeConnection=Humanoid.Changed:connect(O)HumStateConnection=Humanoid.StateEnabledChanged:connect(m)JumpPower=Humanoid.JumpPower JumpStateEnabled=Humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)t()end local function g()CharacterAddedConnection=LocalPlayer.CharacterAdded:connect(h)if LocalPlayer.Character then h(LocalPlayer.Character)end end
--[[ Private Functions ]]
--

local function disableButton()
	JumpButton.Visible = false
	OnInputEnded()
end

local function enableButton()
	if Humanoid and ExternallyEnabled then
		if ExternallyEnabled then
			if Humanoid.JumpPower > 0 then
				JumpButton.Visible = true
			end
		end
	end
end

local function updateEnabled()
	if JumpPower > 0 and JumpStateEnabled then
		enableButton()
	else
		disableButton()
	end
end

local function humanoidChanged(prop)
	if prop == "JumpPower" then
		JumpPower = Humanoid.JumpPower
		updateEnabled()
	elseif prop == "Parent" then
		if not Humanoid.Parent then
			HumChangeConnection:disconnect()
		end
	end
end

local function humandoidStateEnabledChanged(state, isEnabled)
	if state == Enum.HumanoidStateType.Jumping then
		JumpStateEnabled = isEnabled
		updateEnabled()
	end
end

local function characterAdded(newCharacter)
	if HumChangeConnection then
		HumChangeConnection:disconnect()
	end
	-- rebind event to new Humanoid
	Humanoid = nil
	repeat
		Humanoid = MasterControl:GetHumanoid()
		task.wait()
	until Humanoid and Humanoid.Parent == newCharacter
	HumChangeConnection = Humanoid.Changed:connect(humanoidChanged)
	HumStateConnection = Humanoid.StateEnabledChanged:connect(humandoidStateEnabledChanged)
	JumpPower = Humanoid.JumpPower
	JumpStateEnabled = Humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)
	updateEnabled()
end

local function setupCharacterAddedFunction()
	CharacterAddedConnection = LocalPlayer.CharacterAdded:connect(characterAdded)
	if LocalPlayer.Character then
		characterAdded(LocalPlayer.Character)
	end
end
