Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

5 comments

0

What do you mean by "2 keys"?

0

2 Keys as keyboard buttons 2 buttons

0

Do you mean like, for example, you'd press W then Q?

0

yes

0

Ok if no ones gonna answer can this atleast get pinned or something so more people can see it?

1 answer

✓ Accepted answer

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.

1 comment

0

Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.