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

How would i make it so you have to press 2 Buttons to run an animation with userinputservice?

Asked by
exarlus 72
6 years ago
Edited 6 years ago

The title explains it hopefully this is possible.

Script:

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
 if input.KeyCode == Enum.KeyCode.W then
  local Anim = Instance.new('Animation')
  Anim.AnimationId = 'rbxassetid://1667958741'
  PlayAnim = Character.Humanoid:LoadAnimation(Anim)
  PlayAnim:Play()
 end
end)

UIS.InputEnded:connect(function(input)
 if input.KeyCode == Enum.KeyCode.W then
  Character.Humanoid.WalkSpeed = 16
  PlayAnim:Stop()
 end
end)
0
What do you mean by "2 keys"? User#19524 175 — 6y
0
2 Keys as keyboard buttons 2 buttons exarlus 72 — 6y
0
Do you mean like, for example, you'd press W then Q? ax_gold 360 — 6y
0
yes exarlus 72 — 6y
0
Ok if no ones gonna answer can this atleast get pinned or something so more people can see it? exarlus 72 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I'll answer. Yes, it is possible, just follow up lines 6 and 16 and make them something like:

game:WaitForChild(UIS)
if game:WaitForChild(UIS) then
    if UIS:IsKeyDown(Enum.KeyCode.W) and UIS:IsKeyDown(Enum.KeyCode.X) then

Line 3, however, requires the player to press W and X at the same time.

0
Thanks exarlus 72 — 6y
Ad

Answer this question