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)
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)