Tool.Equipped:Connect(function()Character=Tool.Parent HRP=Character:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")Humanoid=Character:WaitForChild("\072\117\109\097\110\111\105\100")equippedIdle=Humanoid:LoadAnimation(script.Animations.Idle)equippedIdle:Play()Equipped.Value=true attackRemote:FireServer("\085\110\098\108\111\099\107",Tool.Name)if not childAdded then childAdded=Character.ChildAdded:Connect(function()if not Equipped.Value then return end if not Player:FindFirstChild("\082\097\103\100\111\108\108")then equippedIdle:Play()else equippedIdle:Stop()end end)end if not childRemoved then childRemoved=Character.ChildRemoved:Connect(function()if not Equipped.Value then return end if not Player:FindFirstChild("\082\097\103\100\111\108\108")then equippedIdle:Play()else equippedIdle:Stop()end end)end end)Tool.Unequipped:Connect(function()equippedIdle:Stop()attackRemote:FireServer("\085\110\098\108\111\099\107",Tool.Name)Equipped.Value=false if childAdded~=nil then childAdded:Disconnect()childAdded=nil end if childRemoved~=nil then childRemoved:Disconnect()childRemoved=nil end end)UIS.InputBegan:Connect(function(Y,n)if n then return end if Y.UserInputType==Enum.UserInputType.MouseButton1 then if not Humanoid then return end if Humanoid.Health>0 then local Y=Character:FindFirstChild("\068\105\115\097\098\108\101\100")if not Y then if UIS:IsKeyDown(Enum.KeyCode.Space)then attackRemote:FireServer("\077\049",Tool.Name,true)else attackRemote:FireServer("\077\049",Tool.Name,false)end;(coroutine.wrap(function()local Y=Instance.new("\066\111\111\108\086\097\108\117\101")Y.Name="\110\111\074\117\109\112"Y.Parent=Character game.Debris:AddItem(Y,1)end))()end end elseif Y.KeyCode==Enum.KeyCode.F then if not Humanoid then return end if Humanoid.Health>0 then local Y=Character:FindFirstChild("\068\105\115\097\098\108\101\100")if not Y then attackRemote:FireServer("\066\108\111\099\107",Tool.Name)end end end end)UIS.InputEnded:Connect(function(Y,n)if n then return end if Y.KeyCode==Enum.KeyCode.F then attackRemote:FireServer("\085\110\098\108\111\099\107",Tool.Name)end end)
-- FUNCTIONS --
Tool.Equipped:Connect(function()
	Character = Tool.Parent
	HRP = Character:WaitForChild("HumanoidRootPart")
	Humanoid = Character:WaitForChild("Humanoid")

	equippedIdle = Humanoid:LoadAnimation(script.Animations.Idle)
	equippedIdle:Play()
	Equipped.Value = true

	attackRemote:FireServer("Unblock", Tool.Name)

	if not childAdded then
		childAdded = Character.ChildAdded:Connect(function()
			if not Equipped.Value then
				return
			end
			if not Player:FindFirstChild("Ragdoll") then
				equippedIdle:Play()
			else
				equippedIdle:Stop()
			end
		end)
	end

	if not childRemoved then
		childRemoved = Character.ChildRemoved:Connect(function()
			if not Equipped.Value then
				return
			end
			if not Player:FindFirstChild("Ragdoll") then
				equippedIdle:Play()
			else
				equippedIdle:Stop()
			end
		end)
	end
end)

Tool.Unequipped:Connect(function()
	equippedIdle:Stop()
	attackRemote:FireServer("Unblock", Tool.Name)

	Equipped.Value = false

	if childAdded ~= nil then
		childAdded:Disconnect()
		childAdded = nil
	end

	if childRemoved ~= nil then
		childRemoved:Disconnect()
		childRemoved = nil
	end
end)

UIS.InputBegan:Connect(function(Input, isTyping)
	if isTyping 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("M1", Tool.Name, true)
				else
					attackRemote:FireServer("M1", Tool.Name, false)
				end
				coroutine.wrap(function()
					local noJumpValue = Instance.new("BoolValue")
					noJumpValue.Name = "noJump"
					noJumpValue.Parent = Character
					game.Debris:AddItem(noJumpValue, 1)
				end)()
			end
		end
	elseif Input.KeyCode == Enum.KeyCode.F then
		if not Humanoid then
			return
		end
		if Humanoid.Health > 0 then
			local Disabled = Character:FindFirstChild("Disabled")
			if not Disabled then
				attackRemote:FireServer("Block", Tool.Name)
			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", Tool.Name)
	end
end)
