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)