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

Releasing the keys stops the animation but if I hold the keys for a while the animation continues?

Asked by
exarlus 72
6 years ago

the title explains it all.

if you hold the keys for a while after releasing the keys the animation loops itself even after the keys aren't being held anymore.

Script:

01local Player = game.Players.LocalPlayer
02local Character = Player.Character
03local UIS = game:GetService'UserInputService'
04local keyCodeQ = Enum.KeyCode.Q
05local keyCode_E = Enum.KeyCode.E
06 
07UIS.InputBegan:Connect(function(input, chatting)
08    if chatting then
09        return
10    end
11 
12    if UIS:IsKeyDown(keyCodeQ) and UIS:IsKeyDown(keyCode_E) then
13         local Anim = Instance.new('Animation')
14  Anim.AnimationId = 'rbxassetid://2007811727'
15  PlayAnim = Character.Humanoid:LoadAnimation(Anim)
View all 28 lines...

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

There is a function called InputEnded and you can use it similar to InputBegan. Inside the InputEnded function you can tell your script to stop.

Ad

Answer this question