-
-
Save kirdaaa/2f04c1448e83d8c0a36ffe9b9b967346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local UIS = game:GetService("UserInputService") | |
local character = script.Parent | |
local humanoid = character:WaitForChild("Humanoid") | |
local animator = humanoid:WaitForChild("Animator") | |
local hrp = character:WaitForChild("HumanoidRootPart") | |
local isCrouching = false | |
local defaultWalkSpeed = 16 | |
local defaultJumpPower = 13 | |
local deb = false | |
local StandToCrouchNoLegs = animator:LoadAnimation(script:WaitForChild("StandToCrouchNoLegs")) | |
local StandToCrouch = animator:LoadAnimation(script:WaitForChild("StandToCrouch")) | |
local CrouchWalkAnim = animator:LoadAnimation(script:WaitForChild("CrouchWalkAnim")) | |
local animateScript = character:WaitForChild("Animate") | |
local defaultWalkAnim = animateScript.walk.WalkAnim.AnimationId | |
local defaultRunAnim = animateScript.run.RunAnim.AnimationId | |
local defaultIdleAnim1 = animateScript.idle.Animation1.AnimationId | |
local defaultIdleAnim2 = animateScript.idle.Animation2.AnimationId | |
local function crouch() | |
isCrouching = true | |
StandToCrouchNoLegs:Play() | |
animateScript.walk.WalkAnim.AnimationId = "rbxassetid://8125946204" | |
animateScript.run.RunAnim.AnimationId = "rbxassetid://8125946204" | |
animateScript.idle.Animation1.AnimationId = "rbxassetid://8141361463" | |
animateScript.idle.Animation2.AnimationId = "rbxassetid://8141361463" | |
humanoid:ChangeState(Enum.HumanoidStateType.Landed) | |
while humanoid.WalkSpeed > 6 do | |
humanoid.WalkSpeed = humanoid.WalkSpeed - 1 | |
wait(.1) | |
end | |
humanoid.JumpPower = 0 | |
end | |
local function stand() | |
isCrouching = false | |
animateScript.walk.WalkAnim.AnimationId = defaultWalkAnim | |
animateScript.run.RunAnim.AnimationId = defaultRunAnim | |
animateScript.idle.Animation1.AnimationId = defaultIdleAnim1 | |
animateScript.idle.Animation2.AnimationId = defaultIdleAnim2 | |
humanoid:ChangeState(Enum.HumanoidStateType.Landed) | |
-- Stop the crouching animation | |
StandToCrouchNoLegs:Stop() | |
while humanoid.WalkSpeed < defaultWalkSpeed do | |
humanoid.WalkSpeed = humanoid.WalkSpeed + 1 | |
wait(.1) | |
end | |
humanoid.JumpPower = defaultJumpPower | |
end | |
UIS.InputBegan:Connect(function(input, isTyping) | |
if input.KeyCode == Enum.KeyCode.C and isTyping == false then | |
if deb == false then | |
if isCrouching == false then | |
deb = true | |
crouch() | |
wait(.2) | |
deb = false | |
else | |
deb = true | |
stand() | |
wait(.2) | |
deb = false | |
end | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment