My block system doesnt work, help please

Hello, I am working on a blocking system and I have a problem.
What I do is create a numerical value in the character with the value of 3. The intention of this is that when they hit you the number goes down one by one.
My problem is that when the value goes from 0 to 3, the lock doesn’t work. Do you have an idea why? I leave you the code and a video

Sword Combat code*

			if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= Player.Name and hit.Parent.IsBlocking.Value == 0 then 

			for _, alreadyHit in pairs(alreadyHitObjects) do 
					if alreadyHit == hit.Parent.Name then 
						return
					end
				end

				alreadyHitObjects[#alreadyHitObjects + 1] = hit.Parent.Name 

			hit.Parent.Humanoid:TakeDamage(6) 
			script.Parent.Sounds.Toca:Play()
			hit.Parent.CanDamage.Value = false
			wait(1)
			hit.Parent.CanDamage.Value = true
		elseif hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= Player.Name and hit.Parent.IsBlocking.Value > 0 then
			for _, alreadyHit in pairs(alreadyHitObjects) do 
				if alreadyHit == hit.Parent.Name then 
					return
				end
			end

			alreadyHitObjects[#alreadyHitObjects + 1] = hit.Parent.Name 
			
			hit.Parent.IsBlocking.Value = hit.Parent.IsBlocking.Value - 1
			hit.Parent.Shield.Transparency = hit.Parent.Shield.Transparency + 0.2

Block code*

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.F and script.Parent.Equipado.Value == true and Debounce == 1 then
		Debounce = 2
		script.RemoteEvent:FireServer()
		hum.JumpPower = 0
		hum.WalkSpeed = 1
		
		character.IsBlocking.Value = 3

		
		Track1:Play()
		
	end
end)

Print commands, print commands, print commands! Check if the event is arriving, going through lines of code, and print the value at the end to see if it changed!

2 Likes

It is not printing, what can I do?

Just put a print command and see exactly which line the problem is! From there you bug fix that line

For example to localize it
Print(line 4 succeeded)
Line 5
Print(line 5 succeeded)
Line 6
#print command that didn’t work etc

Oh Simple Your Changing The Value As The Client Not As The Server Just Change The Value As The Server Would Solve It

You are changing the value from the client instead of the server.
While in play-mode, click this:
image
& change the value.

That way it should work.

How could you apply it to the players? From the script it changes but the same thing happens that happened to the npc

You need to make it fully server-sided with regular scripts. LocalScripts run on the clients and will only make that change for them.
You putting the line containing character.IsBlocking.Value = 3 to the script which receives the RemoteEvent’s event should fix it

Thank you so much!! it works now