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

Animation on key press isn't working, can someone help? (me and my team are fairly new to Lua)

I am making an ability based game and I have an ability that when I press Q I gain movement speed and become semi-transparent. We (this is a group game using team create) made an animation for activating the ability, but it isn't working. Here is the LocalScript,

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

	local debounce = false

	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id=6271298217"

	mouse.KeyDown:connect(function(key)
	    if key == "q" then
	     local playAnim = humanoid:LoadAnimation(anim)


    		    if not debounce then

   		     debounce = true
	
     		   playAnim:Play()

    		    wait(6)

    		    debounce = false

  		  end
	   end
	end)

1 answer

You can search the toolbox for useful but easy scripts like that! Here:

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

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=6271298217" -- id of animation (I put it for you)

mouse.KeyDown:connect(function(key)
	if key == "q" then
		local playAnim = humanoid:LoadAnimation(anim)
		playAnim:Play()
	end
end)

Mind if you can show me what animation is that? Only the creator of the animation can put it in roblox studio :)

2 comments

0

BTW be sure to put it in StarterGUI or StarterPack

0

You can put the debounce back if you like!

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