#Help for scrip attack block

4 messages · Page 1 of 1 (latest)

lilac leaf
#

i only scripted the playing animation lines and the walking speed for now but i don't know why the animation doesn't play and all it works is the walking speed

local UIS = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")

local walkspeed = hum.WalkSpeed
local blockwaklkspeed = walkspeed / 2

local playanim  -- declare the variable here

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
        hum.WalkSpeed = blockwaklkspeed
        local anim = script.Block
        playanim = hum:LoadAnimation(anim)
        playanim:Play()
    end
end)

UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
        hum.WalkSpeed = walkspeed
        playanim:Stop()
    end
end)```
weary elk
#

why are you changing the variable there

#
local UIS = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")

local walkspeed = hum.WalkSpeed
local blockwaklkspeed = walkspeed / 2

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
        hum.WalkSpeed = blockwaklkspeed
        anim = script.Block
        playanim = hum:LoadAnimation(anim)
        playanim:Play()
    end
UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
        hum.WalkSpeed = walkspeed
        playanim:Stop()
    end
end)
end)```
#

you can remove the local for it to be used everywhere