I can't seem to get true of false values to work

I was making a combat system. While I was doing that I was working on my blocking system I encounterd a problem. So basiclly I got all the player descendants and I checked if the one desecndant of player is a bool value. If it is then I check if that value is true of false. If it is true, then that means the other player is blocking and then the damage I do is 1, if blocking is false, then the damage I do is 2.5.
PROBLEM: It only seems to be sticking with the regular damage. It isn’t checking if the player is blocking or not everytime I click.

Here is the script:

local combat = script.Parent

local ReplicatedStorage = game.ReplicatedStorage
local CombatEvent = ReplicatedStorage.CombatEvent

local equipped = false

local damage = 2.5
local BlockDamage = 1

combat.Equipped:Connect(function()
	equipped = true
	print(equipped)
	character = combat.Parent
	--local ourPlayer = game.Players:GetPlayerFromCharacter(character)
end)

combat.Unequipped:Connect(function()
	equipped = false
	print(equipped)
end)

local function checkIfHitAndBlocking()
	for i,player in pairs(game.Workspace:GetChildren()) do
		if player:IsA("Model") then
			if player.Humanoid and player.HumanoidRootPart then
				if player ~= character then
				print("model with humanoid found")
				local playerHumanoidRootPart = player.HumanoidRootPart
				local ourHumanoidRootPart = character.HumanoidRootPart
					local magnitude = (ourHumanoidRootPart.Position - playerHumanoidRootPart.Position).Magnitude
					local unit = (ourHumanoidRootPart.Position - playerHumanoidRootPart.Position).Unit
					local dot = unit:Dot(character.Head.CFrame.LookVector)
					if magnitude <= 2 and dot <= 0.5 then
						local desecandants = player:GetDescendants()
						for i, desecandant in pairs(desecandants) do
							if desecandant:IsA("BoolValue") then
								local PlayerIsBlocking = desecandant
									if PlayerIsBlocking.Value == true then
										player.Humanoid:TakeDamage(damage)
									elseif PlayerIsBlocking.Value == false then
										player.Humanoid:TakeDamage(BlockDamage)
								end
							end
						end
					end
			   	 end
			end
		end
	end
end

CombatEvent.OnServerEvent:connect(checkIfHitAndBlocking)

Is there only one BoolValue where you check for it?

I put the bool value inside every players tool.

And the value is getting set properly.

Yes I have a seperate script that sets the value aswell.

Not sure if it’s the root of the problem, but you have it set to where you take 2.5 damage when blocking and 1 when not blocking.

o_o i didnt realize that…I will fix that

Mark his post as the solution!

It still does 1 damage. I set the npc blocking value to true, it does 1, I set it to false, it still does 1…

If you’re setting the blocking value during runtime in Studio, the changes will only happen locally unless you toggle to Server.

Oh so it would Only work if I do it in a server. I am trying playing solo btw.

I got an idea, i use this in my own combat script

if PlayerIsBlocking.Value ~= false then
 player.Humanoid:TakeDamage(BlockDamage)
else
 player.Humanoid:TakeDamage(Damage)
end

I have a script inside the npc that determines the blocking
I took my dog for a walk sorry if I waited so long to reply

local npc = script.Parent

local Blocking = npc:FindFirstChild("PlayerIsBlocking")
Blocking.Value = false

Alright I think I know what the problem is, I haven’t tried it yet but I think it is the fact that I was setting Blocking.Value false before I played solo. therefore, it will probably stay false no matter what.

I found a solution, the problem wasn’t in the script. It was in the NPC.
here is the script

local npc = script.Parent

local Blocking = npc:FindFirstChild("PlayerIsBlocking")
Blocking.Value = true

while wait(1) do
	Blocking.Value = true
	if Blocking.Value == true then
		print("NPC BLOCKING")
		wait(10)
		Blocking.Value = false
		if Blocking.Value == false then
			print("NPC NOT BLOCKING")
		end
	end
end

So before I changed the script, I noticed that I set the value to false or true on the old script. Doing that, it will stay that way no matter what I change. But on this script, I looped it. It works now, so when npc is blocking, it does 1 damage. When not blocking, 2.5 damage. I appreciate everyone for helping me!