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

animation loops when pressing the keys while pressing another key at the same time?

Asked by
axxull 14
6 years ago

So the animation doesen't loop and when you release the 2 keys Q and E the animation stops but if you press Q and E and other button while holding Q and E the animation will loop for some reason?

local UIS = game:GetService'UserInputService'
local Player = game.Players.LocalPlayer
local Character = Player.Character
local keyCodeQ = Enum.KeyCode.Q
local keyCodeE = Enum.KeyCode.E



   UIS.InputBegan:Connect(function(input)
    if UIS:IsKeyDown(keyCodeQ) and UIS:IsKeyDown(keyCodeE) then
        local Anim = Instance.new('Animation')
  Anim.AnimationId = 'rbxassetid://2007811727'
  PlayAnim = Character.Humanoid:LoadAnimation(Anim)
  PlayAnim:Play()
    end
end)


    UIS.InputEnded:Connect(function(input)
    if not UIS:IsKeyDown(keyCodeQ) or UIS:IsKeyDown(keyCodeE) then
        PlayAnim:Stop()
    end 
end)

Answer this question