Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animation with keyDown, No tool?

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?id=187720963"

local Player = game.Players.LocalPlayer
local Mouse =  Player:GetMouse()
local animTrack = nil
local canPlay = true

Mouse.KeyDown:connect(function(key)
	if key == "q" then
		local player = game.Players.LocalPlayer.Character
		animTrack = player.Humanoid:LoadAnimation(animation) --Load the animation Senpai
		animTrack.KeyframeReached:connect(function(keyframeName)
		canPlay = true
		end)
	end
end)

Mouse.KeyDown:connect()

So confused on why it doesnt work e.o

2 comments

1

Line 19 is not necessary, since you are not calling a function.

0

Perhaps set a parent for "Animation." Also, I believe Roblox's Id format is this: "http://www.roblox.com/assets/?id=187720963" or "rbxassetid://187720963"

1 answer

This doesn't work because you never play the animation. There are some other problems, however.

Line 19 is not needed. You used an anonymous function, so the connection is on line 09, when you create it.

There is no need for the canPlay variable because you have it set to true no matter what.

player is a bad name for that variable because the variable equals the character, not the player, which you already have a variable for.

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?id=187720963"

local Player = game.Players.LocalPlayer
local Mouse =  Player:GetMouse()
local animTrack = nil

Mouse.KeyDown:connect(function(key)
	if key:lower() == "q" then
		local character = Player.Character
		animTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation) 
		animTrack:Play()
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.