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

How do I make an animation stop playing via press of "G"?

Asked by 5 years ago
Edited by User#5423 5 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
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=(my id is here)"
08 
09mouse.KeyDown:connect(function(key)
10    if key == "r" then
11        local playAnim = humanoid:LoadAnimation(anim)
12        playAnim:Play()
13game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
14game.StarterPlayer.EnableMouseLockOption = false
15game.StarterPlayer.AutoJumpEnabled = false
View all 22 lines...
1
I think you should use UserInputService instead of Player.Mouse. Because you want to check is key "r" and key "g" is pressing or not. And you should use GetPlayingAnimationTracks ( ) to get the AnimationTracks from Animation, because AnimationTracks has :Stop() function. Block_manvn 395 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago
1local player = game.Players.LocalPlayer repeat wait() until player.Character.Humanoid
2 
3local humanoid = player.Character.Humanoid
4 
5local mouse = player:GetMouse()
6 
7local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=(my id is here)"
8mouse.KeyDown:connect(function(key) if key == "r" then local playAnim = humanoid:LoadAnimation(anim) playAnim:Play() game:GetService("StarterGui"):SetCore("ResetButtonCallback", false) game.StarterPlayer.EnableMouseLockOption = false game.StarterPlayer.AutoJumpEnabled = false game. wait(3.2) game:GetService("StarterGui"):SetCore("ResetButtonCallback", true) game.StarterPlayer.EnableMouseLockOption = true game.StarterPlayer.AutoJumpEnabled = true end end)
0
I dont know any answers, but this is the script Shadic1270 136 — 5y
0
I don't think thats an answer.. you just copied my code, pasted it and said it was the answer... this doesn't solve anything xDreamingLuma -3 — 5y
0
i already said i dont know any answer, i just posted it so people could understand Shadic1270 136 — 5y
Ad

Answer this question