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

Why isn't my animation playing in this KeyDown script?

Asked by
rexpex 45
7 years ago

So i made a punching script that activates when you press q but it isn't working. There are no error warnings on my output or script analysis. Please help.

local Player = game.Players.LocalPlayer
    local mouse = Player:GetMouse()
    local Humanoid = Player.Character.Humanoid
    local debounce = false
    mouse.KeyDown:connect(function(key)
        if not debounce then
            debounce = true

        if key == "q" then


        local Punch = Instance.new("Animation")
        Punch.AnimationId = "http://www.roblox.com/Asset?ID=644505212"
        local animTrack = Humanoid:LoadAnimation(Punch) 
        print("fart")
    animTrack:Play()

wait(1)
debounce = false

        end
        end

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You don't need that long of a script to just play an animation when a key is pressed. The reason why the animation doesn't play is because you forgot end) at the very bottom line.

If I'm wrong - I redid it just in case.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local humanoid = player.Character.Humanoid

mouse.KeyDown:connect(function(key)
    if key == "q" then
        local anim = Instance.new("Animation")
        anim.AnimationId = "" -- Animation ID goes here
        local animTrack = humanoid:LoadAnimation(anim)
        animTrack:Play()
    end
end)
0
The other possible reason why - The animation must be made by you or an open sourced animation made by the user ROBLOX, or else it cannot work. There is a possible way to download ROBLOX animations to game.Workspace using loadstring(getobjects) but I forgot that. User#12753 0 — 7y
Ad

Answer this question