Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

help my blocking animation is not stoping!?

Asked by
Tizzel40 243 Moderation Voter
5 years ago
Edited 5 years ago

so when thr "F" Button is DOWN the animation plays but when I let go of the F Button its still plays and doesn't stop!!

why?

local Remote = script.Parent:WaitForChild("Remotes").damage         
local play = game.Players.LocalPlayer
local use = false
local uis = game:GetService("UserInputService")

script.Parent.Equipped:Connect(function()-----only should work when equiped


uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
    if use == false then

        use = true
    print("now blocking")
    local hitanim = script.Parent.Animations.Blocking   
    local hitplay = play.Character.Humanoid:LoadAnimation(hitanim)
hitplay:Play()
Remote:FireServer()
wait(.7)------------cooldown number
use = false
    end
    end
end)
uis.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then

    print("just stoped blocking")
    local hitanim = script.Parent.Animations.Blocking   
    local hitplay = play.Character.Humanoid:LoadAnimation(hitanim)
hitplay:Stop()
    end
    end)
    end)

1 answer

Log in to vote
0
Answered by
552557 20
5 years ago

You are not assigning the Animation Track created by the humanoid, using ":LoadAnimation()" creates a new Animation Track everytime.

local Remote = script.Parent:WaitForChild("Remotes").damage         
local play = game.Players.LocalPlayer
local use = false
local uis = game:GetService("UserInputService")

script.Parent.Equipped:Connect(function()-----only should work when equiped

local hitanim = script.Parent.Animations.Blocking  
local hitplay = play.Character.Humanoid:LoadAnimation(hitanim)

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
    if use == false then

        use = true
    print("now blocking")

hitplay:Play()
Remote:FireServer()
wait(.7)------------cooldown number
use = false
    end
    end
end)
uis.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then

    print("just stoped blocking")
hitplay:Stop()
    end
    end)
    end)

Ad

Answer this question