-- FUNCTIONS --

Tool.Equipped:Connect(function()
	Character = Tool.Parent
equiped = true
Player.PlayerGui:FindFirstChild("Fists").Enabled = true

	Character.Humanoid.Running:Connect(function(speed)

		if speed == 0 and Equipped.Value == true then -- Walking
			equippedIdle:Play()

		else -- Idle
			equippedIdle:Stop()

		end
	end)
	HRP = Character:WaitForChild("HumanoidRootPart")
	Humanoid = Character:WaitForChild("Humanoid")

	
	
	
	attackRemote:FireServer("Equip")
	attackRemote:FireServer("Unblock")
	val.Value = false

end)

Tool.Unequipped:Connect(function()
	Player.PlayerGui:FindFirstChild("Fists").Enabled = false
	equiped = false
	equippedIdle:Stop()
	attackRemote:FireServer("Unequip")

	attackRemote:FireServer("Unblock")
	val.Value = false	

end)

UIS.InputBegan:Connect(function(Input, isTyping)
	if isTyping then return end

	if Player.Character:FindFirstChild("PBSTUN") then return end
	if Player.Character:FindFirstChild("Running").Value == true then return end
	if Input.UserInputType == Enum.UserInputType.MouseButton1 then
		if not Humanoid then return end
		if Humanoid.Health > 0 then
			local Disabled = Character:FindFirstChild("Disabled")
			if not Disabled then
				
				if UIS:IsKeyDown(Enum.KeyCode.Space) then
					attackRemote:FireServer("Attack", true)
				else
					attackRemote:FireServer("Attack", false)
				end
		
				coroutine.wrap(function()
					local noJumpValue = Instance.new("BoolValue")
					noJumpValue.Name = "noJump"
					noJumpValue.Parent = Character
					game.Debris:AddItem(noJumpValue, 1.4)
				end)()
			end
		end
	
	elseif Input.KeyCode == Enum.KeyCode.F then
		if deb == true then return end
		if not Humanoid then return end
		if Humanoid.Health > 0 then
			local Disabled = Character:FindFirstChild("Disabled")
			if not Disabled then
				val.Value = true
			deb = true
				attackRemote:FireServer("Block")
				wait(1)
				deb = false
			end
		end

	end
end)

UIS.InputEnded:Connect(function(Input, isTyping)
	if isTyping then return end

	if Input.KeyCode == Enum.KeyCode.F then
		attackRemote:FireServer("Unblock")
		val.Value = false
	
	end
end)
