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

Why isn't my animation playing in this KeyDown script?

So i made a punching script that activates when you press q but it isn't working. There are no error warnings on my output or script analysis. Please help.

local Player = game.Players.LocalPlayer
	local mouse = Player:GetMouse()
	local Humanoid = Player.Character.Humanoid
	local debounce = false
	mouse.KeyDown:connect(function(key)
		if not debounce then
			debounce = true
		
		if key == "q" then
				
		
		local Punch = Instance.new("Animation")
		Punch.AnimationId = "http://www.roblox.com/Asset?ID=644505212"
		local animTrack = Humanoid:LoadAnimation(Punch)	
		print("fart")
	animTrack:Play()
			
wait(1)
debounce = false
		
		end
		end

1 answer

You don't need that long of a script to just play an animation when a key is pressed. The reason why the animation doesn't play is because you forgot end) at the very bottom line.

If I'm wrong - I redid it just in case.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local humanoid = player.Character.Humanoid

mouse.KeyDown:connect(function(key)
	if key == "q" then
		local anim = Instance.new("Animation")
		anim.AnimationId = "" -- Animation ID goes here
		local animTrack = humanoid:LoadAnimation(anim)
		animTrack:Play()
	end
end)

1 comment

0

The other possible reason why - The animation must be made by you or an open sourced animation made by the user ROBLOX, or else it cannot work. There is a possible way to download ROBLOX animations to game.Workspace using loadstring(getobjects) but I forgot that.

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