I'm trying to make a script that allows players to play a crouching animation, move slower, and jump lower when the R1 button is pressed, the player crouches and their mobility is reduced, but they won't return to the idle animation when the button is released, I'm sure the problem has to do with how the crouching script is below the idle script. (Note: The script is based off the "run with the R1 button" script.)
-- Make character stand if R1 is released
if input.KeyCode == Enum.KeyCode.ButtonR1 then
character.Humanoid.WalkSpeed = 22
character.Humanoid.JumpPower = 50
end
end
end)
-- Check for user input began events. This handles ducking.
userInputService.InputBegan:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
-- If R1 is pressed then make the character duck.
if input.KeyCode == Enum.KeyCode.ButtonR1 then
local duck = character.Humanoid:LoadAnimation(script.Parent.Crouch)
duck:Play()
character.Humanoid.WalkSpeed = 6
character.Humanoid.JumpPower = 25
end
end
end)
