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 if im not pressing the key anymore?

Asked by
exarlus 72
6 years ago
Edited 6 years ago

Basically i have a on Key press animation script. But the only problem is that the animation still plays even when im not clicking the button anymore.

I even made a new script with input service and it still doesen't work

--and get the player and character and humanoid local player = game:GetService("Players").LocalPlayer local character = player.Character or player.Character:Added() local humanoid = character:WaitForChild("Humanoid") --Next we make our animation local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://1297032259" --Now we can make a function to play animations! function playAnimation(Anim) local track = humanoid:LoadAnimation(Anim) track:Play() end --Now we play it when using the userinputservice game:GetService("UserInputService").InputBegan:connect(function(input ,proc) if not proc then if input.KeyCode == Enum.KeyCode.D then --get the F key using Enum playAnimation(anim) --plays our animation using our function :) end end end)

0
Use UserInputService because KeyDown is deprecated, and then you can use InputEnded to detect key release. mattscy 3725 — 6y
0
Anyway to learn this? Is it on wiki? exarlus 72 — 6y
0
Yes search userinputservice roblox. Mr_MilkysButler 47 — 6y
0
NVM I figured this out Thanks guys! exarlus 72 — 6y

Answer this question