Answered by
5 years ago Edited 5 years ago
We ended up solving it on discord. Took a while but we got it done. Here is the final result:
If you are reading this and have any question, post them below pls and I'll get back to u.
01 | local UIS = game:GetService( 'UserInputService' ) |
02 | local Player = game.Players.LocalPlayer |
03 | local Character = Player.Character |
05 | local isCrouching = false |
07 | idleCrouchAnimation = nil |
13 | UIS:IsKeyDown(Enum.KeyCode.LeftShift) and UIS:IsKeyDown(Enum.KeyCode.LeftShift) |
14 | or UIS:IsKeyDown(Enum.KeyCode.W) and UIS:IsKeyDown(Enum.KeyCode.LeftShift) |
15 | or UIS:IsKeyDown(Enum.KeyCode.A) and UIS:IsKeyDown(Enum.KeyCode.LeftShift) |
16 | or UIS:IsKeyDown(Enum.KeyCode.S) and UIS:IsKeyDown(Enum.KeyCode.LeftShift) |
17 | or UIS:IsKeyDown(Enum.KeyCode.D) and UIS:IsKeyDown(Enum.KeyCode.LeftShift) |
23 | UIS.InputBegan:Connect( function (input, gameProcessedEvent) |
25 | if input.KeyCode = = Enum.KeyCode.C and not isOnCooldown then |
33 | if not isCrouching then |
35 | Character.Humanoid.WalkSpeed = 6 |
37 | local animation = Instance.new( 'Animation' ) |
39 | idleCrouchAnimation = Character.Humanoid:LoadAnimation(animation) |
41 | idleCrouchAnimation:Play() |
46 | idleCrouchAnimation:Stop() |
47 | Character.Humanoid.WalkSpeed = 16 |
57 | elseif input.KeyCode = = Enum.KeyCode.W and isCrouching then |
58 | local animation = Instance.new( 'Animation' ) |
60 | sneakAnimation = Character.Humanoid:LoadAnimation(animation) |
68 | UIS.InputBegan:Connect( function (input, gameProcessedEvent) |
69 | print (isRunning(), sneakAnimation) |
70 | if isRunning() and sneakAnimation then |
75 | if (input.KeyCode = = Enum.KeyCode.LeftShift and UIS:IsKeyDown(Enum.KeyCode.W)) |
76 | or (input.KeyCode = = Enum.KeyCode.W and UIS:IsKeyDown(Enum.KeyCode.LeftShift)) then |
77 | idleCrouchAnimation:Stop() |
82 | UIS.InputEnded:Connect( function (input, gameProcessedEvent) |
83 | if input.KeyCode = = Enum.KeyCode.W and sneakAnimation then |