Whats wrong with my script? (walking makes me stop blocking

local char = game.Players.LocalPlayer.Character

local hum = char:WaitForChild("Humanoid") --gets the humanoid

local anim1 = hum:LoadAnimation(script:WaitForChild("BlockAnim"))

local blockingval = char:WaitForChild("Blocking")

anim1:Play()

game:GetService("UserInputService").InputBegan:connect(function(input) -- Input Began checks if the player presses anything and fires whenever the player does so.

if input.KeyCode == Enum.KeyCode.F then -- This detects for a "e" press.

blockingval.Value = true

script.Cloth:Play()

anim1:Play()

hum.WalkSpeed = 6

end

end)

game:GetService("UserInputService").InputEnded:connect(function(input) -- Fires when input ended

blockingval.Value = false

anim1:Stop()

hum.WalkSpeed = 16

end)

the script works perfectly fine but whenever i stop walking the script stops

as you can see when my player stops moving so does my blocking script

That happens because you made it so you stop blocking no matter what button you stop pressing.

Specifically this chunk:

1 Like

The guy above me got in correct.

Add if input.KeyCode == Enum.KeyCode.F then, after the Input ended event

2 Likes

how could i fix this? ᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼

wait nvm lol ᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼

thank you! ᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼

your a life saver thank you! ᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼᲼

1 Like