I tried to make a animation play by pressing Q. Nothing happened. Can you guys help me out?
local UserInputService = game:GetService("UserInputService") local localPlayer = game.Players.LocalPlayer
local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=492283384"
local animTrack = nil local canPlay = true local function onInputBegan(input, gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard then local keyPressed = input.KeyCode if keyPressed == Enum.KeyCode.Q then local player = game.Players.LocalPlayer.Character canPlay = false animTrack = player.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid animTrack.KeyframeReached:connect(function(keyframeName) -- Bind function to KeyframeReached event if keyframeName == "ElectrocuteEnd" then canPlay = true end end end end local function onInputEnded(input, gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard then local keyPressed = input.KeyCode if keyPressed == Enum.KeyCode.Q then local player = game.Players.LocalPlayer.Character canPlay = false animTrack = player.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid animTrack.KeyframeReached:connect(function(keyframeName) -- Bind function to KeyframeReached event if keyframeName == "ElectrocuteEnd" then canPlay = false end end end UserInputService.InputBegan:connect(onInputBegan) UserInputService.InputEnded:connect(onInputEnded)
You can use this instead its not mine so i wont use it for my game ;p
Animation = Instance.new("Animation") Animation.Parent = game.Workspace Animation.AnimationId = "http://www.roblox.com/asset/?id=ID HERE" --Where It Says ID HERE, Place Your Animation Id local Player = game.Players.LocalPlayer local mouse = game.Players.LocalPlayer:GetMouse() mouse.KeyDown:connect(function (key) for i, v in pairs(game.Players:GetChildren()) do if key == "f" then -- THIS IS UR KEY U WANA CHANGE IT CHANGE F TO SOMETHING ELSE local AnimationTrack = Player.Character.Humanoid:LoadAnimation(Animation) AnimationTrack:Play() end end end)
That is all ;)
Dont forget to accept my answer