Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Mekski 0
4 years ago

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,

01local player = game.Players.LocalPlayer
02repeat wait() until player.Character.Humanoid
03local humanoid = player.Character.Humanoid
04local mouse = player:GetMouse()
05 
06    local debounce = false
07 
08    local anim = Instance.new("Animation")
09    anim.AnimationId = "http://www.roblox.com/asset/?id=6271298217"
10 
11    mouse.KeyDown:connect(function(key)
12        if key == "q" then
13         local playAnim = humanoid:LoadAnimation(anim)
14 
15 
View all 28 lines...

1 answer

Log in to vote
0
Answered by 4 years ago

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

01local player = game.Players.LocalPlayer
02repeat wait() until player.Character.Humanoid
03local humanoid = player.Character.Humanoid
04local mouse = player:GetMouse()
05 
06local anim = Instance.new("Animation")
07anim.AnimationId = "http://www.roblox.com/asset/?id=6271298217" -- id of animation (I put it for you)
08 
09mouse.KeyDown:connect(function(key)
10    if key == "q" then
11        local playAnim = humanoid:LoadAnimation(anim)
12        playAnim:Play()
13    end
14end)

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

0
BTW be sure to put it in StarterGUI or StarterPack qMrSpooky 20 — 4y
0
You can put the debounce back if you like! qMrSpooky 20 — 4y
Ad

Answer this question