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

My animation won't play, or deal damage?

Asked by 8 years ago

I have made a punching animations, and I would like to have it play on a key bind. I have got it to work at one point, but tried to make it do damage. I could not remember how I made it, and I'm not sure what I'm doing wrong. If someone could show me an example of how to make my animation play, and for it to deal damage. It would help my greatly. Nothing I have tried is helping me. Below is the current animation playing script I have tried.

local animation = Instance.new("Animation")
animation.AnimationId = "424824892"
local Humanoid = nil
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end
Humanoid = character:WaitForChild("Humanoid")
local animTrack = Humanoid:LoadAnimation(animation)
function onKeyDown(key)
    key = key:lower()
    if key == "e" then
    animTrack:Play()
    end
end
script.Parent.Parent:GetMouse().KeyDown:connect(onKeyDown)

Answer this question