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
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)