Why isn't my blocking script working?

Hey there, I was wondering if anyone knew why my sword would break if you attack while blocking?
Basically when you attack while blocking, it doesn’t let you attack anymore.

This is what happens in game if you try to attack while blocking:

It works with a string value inside your character that is either “true” or “false”
when you attack it determines if you are blocking, and then if the player you hit has “true” or “false” on.

Starter Character:
Screenshot 2024-01-20 181522

WorkSpace:
Screenshot 2024-01-20 181434

Sword Server Script:

--CONFIGURATION
local Turn = 1
local Damage = 35
local Cooldown = 2

local players = game:GetService("Players")


local BlockEvent = script.Parent:WaitForChild("BlockRemote")
local BlockStopEvent = script.Parent:WaitForChild("BlockStopRemote")

local UserInputService = game:GetService("UserInputService")
local tool = script.Parent
local mesh = script.Parent.Handle

local player = tool.Parent.Parent 
local character = player.Character


script.Parent.Activated:Connect(function()
	if script.Parent.Cooldown.Value == false then
		script.Parent.Cooldown.Value = true
		script.Parent.CanDamage.Value = true

		local Humanoid = script.Parent.Parent.Humanoid
		local Anim1 = Humanoid:LoadAnimation(script.Parent.Attack1)
		local Anim2 = Humanoid:LoadAnimation(script.Parent.Attack2)
		local Anim3 = Humanoid:LoadAnimation(script.Parent.Attack3)
		local Slash = script.Parent.Slash


		if Turn == 1 then
			if character.Blocking.Value == "false" then
				Anim1:Play()
				Turn = 2

				Anim1.Stopped:wait(Cooldown)
				script.Parent.CanDamage.Value = false
				script.Parent.Cooldown.Value = false
				wait(.3)
				Slash:Play()
			end
		elseif Turn == 2 then
			if character.Blocking.Value == "false" then
				Anim2:Play()
				Turn = 3

				Anim2.Stopped:Wait(Cooldown)
				script.Parent.CanDamage.Value = false
				script.Parent.Cooldown.Value = false
				Slash:Play()
			end
		elseif Turn == 3 then
			if character.Blocking.Value == "false" then
				Anim3:Play()
				Turn = 1

				Anim3.Stopped:Wait(Cooldown)
				script.Parent.CanDamage.Value = false
				script.Parent.Cooldown.Value = false
				wait(.2)
				Slash:Play()
			end
		end
	else
		
	end
end)

script.Parent.Handle.Touched:Connect(function(Hit)
	if character.Blocking.Value == "false" then
		if Hit.Parent:FindFirstChild("Humanoid") then
			local Humanoid = Hit.Parent.Humanoid
			local character = Hit.Parent
			local player = players:GetPlayerFromCharacter(character)
			if character.Blocking.Value == "false" then
				if script.Parent.CanDamage.Value == true then
					Humanoid:TakeDamage(Damage)
					script.Parent.CanDamage.Value = false
				else
				
				end
			end
		end
	end
end)

local function Block ()
	script.Parent.Parent:FindFirstChild("Blocking").Value = "true"
end

BlockEvent.OnServerEvent:Connect(Block)

local function UnBlock ()
	script.Parent.Parent:FindFirstChild("Blocking").Value = "false"
end

BlockStopEvent.OnServerEvent:Connect(UnBlock)

Sword Client Script:

wait()
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")



local tool = script.Parent
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local isEquipped = false
local BlockEvent = script.Parent:WaitForChild("BlockRemote")
local BlockStopEvent = script.Parent:WaitForChild("BlockStopRemote")


-- Ensure that the character's humanoid contains an "Animator" object
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

-- Create a new "Animation" instance and assign an animation asset ID
local kickAnimation = script.Parent:WaitForChild("BlockAnimation")

-- Load the animation onto the animator
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)

local function onEquipped(_mouse)
	isEquipped = true
	print("The tool was equipped")
end
tool.Equipped:Connect(onEquipped)

tool.Unequipped:Connect(function()
	isEquipped = false
	print("The tool was unequipped")
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		if isEquipped == true then
			BlockEvent:FireServer()
			kickAnimationTrack:Play()
		end
	end
end)

UserInputService.InputEnded:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		if isEquipped == true then
			BlockStopEvent:FireServer()
			kickAnimationTrack:Stop()
		end
	end
end)

Please help me :slight_smile:

Now, I’m not familiar with using quotes around true/false, remove the quotes and see if it helps.

Hey I fixed the issue, (i kinda forgot what the solve was), but thanks for the reply, also it was not a boolVal, but a string value.