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)

2 comments
That's a free model script though...
No. It's not.