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 4 years ago
Edited by User#5423 4 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.
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=(my id is here)" 

mouse.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)
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 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago
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=(my id is here)"
mouse.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 — 4y
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 — 4y
0
i already said i dont know any answer, i just posted it so people could understand Shadic1270 136 — 4y
Ad

Answer this question