I don't know too much about animations sooo idk what I did wrong
game.Players.PlayerAdded:Connect(function(plr) local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.F then local animation = Instance.new("Animation") animation.AnimationId = "3560009028" local animTrack = nil local canPlay = true function playShockAnim() if canPlay then local player = plr canPlay = false animTrack = player.Humanoid:LoadAnimation(animation) canPlay = true animTrack:Play() end end playShockAnim(plr) end end) end)
Ok so your formatting is a little confusing but when a rearranged it, it looks like this
game.Players.PlayerAdded:Connect(function(plr) local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.F then local animation = Instance.new("Animation") animation.AnimationId = "3560009028" local animTrack = nil local canPlay = true function playShockAnim() if canPlay then local player = plr canPlay = false animTrack = player.Humanoid:LoadAnimation(animation) canPlay = true animTrack:Play() end end playShockAnim(plr) end end) end) -- extra end)?
I don't understand why you have a function defined when the player presses f instead of just doing what the function does. The real problem is that the animation ID should be "rbxassetid://3560009028" instead of just "3560009028", which is probably why your animation isn't playing, also you should make your animation priority higher so it doesn't get interupted by movement animations.