local function e()JumpButton.Visible=false OnInputEnded()end local function C()if Humanoid and ExternallyEnabled then if ExternallyEnabled then if Humanoid.JumpPower>0 then JumpButton.Visible=true end end end end local function N()if JumpPower>0 and JumpStateEnabled then C()else e()end end local function L(e)if e=="\074\117\109\112\080\111\119\101\114"then JumpPower=Humanoid.JumpPower N()elseif e=="\080\097\114\101\110\116"then if not Humanoid.Parent then HumChangeConnection:disconnect()end end end local function H(e,C)if e==Enum.HumanoidStateType.Jumping then JumpStateEnabled=C N()end end local function r(e)if HumChangeConnection then HumChangeConnection:disconnect()end Humanoid=nil repeat Humanoid=MasterControl:GetHumanoid()wait()until Humanoid and Humanoid.Parent==e HumChangeConnection=Humanoid.Changed:connect(L)HumStateConnection=Humanoid.StateEnabledChanged:connect(H)JumpPower=Humanoid.JumpPower JumpStateEnabled=Humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)N()end local function g()CharacterAddedConnection=LocalPlayer.CharacterAdded:connect(r)if LocalPlayer.Character then r(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()
		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
