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

Key Press Animation Won't Play?

Asked by 6 years ago

When you touch this brick, it will clone this local script into the players Gui. However, it doesn't work whenever I press h...


local Mouse = game.Players.LocalPlayer:GetMouse() local chr = game.Players.LocalPlayer.Character function onKeyDown(key) key = key:lower() if key == "h" then local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=1567452314" wait() local trackanimation = chr.Humanoid:LoadAnimation(animation) trackanimation:Play() end end Mouse.KeyDown:connect(onKeyDown)

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Human = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local anim = Instance.new("Animation", Human)
anim.AnimationId = "http://www.roblox.com/asset/?id=01468567293" --Type your animation id here

mouse.KeyDown:connect(function(key)
        key = key:lower()
    if key == 'h' then
            local animTrack = Human:LoadAnimation(anim)
            animTrack:Play()
    end
end)

This script should work.

And don't make it in local script, use normal script.

Ad

Answer this question