This script plays an animation when 2 buttons are pressed. However I want the animation to stop whenever one of the keys are released.I tried doing "If not" for one of the keys.. but it still never works.
local uis = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local human = Character:WaitForChild("Humanoid")
local Anim = script.WalkFoward
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Z or input.KeyCode == Enum.KeyCode.X then
local keys = uis:GetKeysPressed()
local xFound, zFound
for _, key in pairs(keys) do
if key.KeyCode == Enum.KeyCode.Z then
zFound = true
elseif key.KeyCode == Enum.KeyCode.X then
xFound = true
end
end
if zFound and xFound then
PlayAnim:Play()
end
end
end)

1 comment
thanks