Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

help my blocking animation is not stoping!?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.