I am trying to implement a simple crouching mechanic. I simply adust the hip height from 0 to -2 when crouched but when this happens the character bounces alot when it hits the ground. How can I stop this bouncing?
-- LocalScript
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid:Humanoid = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
humanoid:ChangeState(Enum.HumanoidStateType.Running)
local normalHipHeight = humanoid.HipHeight
local crouchHipHeight = normalHipHeight-2
local crouched = false
UserInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.C then
crouched = not crouched
humanoid.HipHeight = crouched and crouchHipHeight or normalHipHeight
end
end)
Issue video:
I do also notice that the character maybe goes into the falling state becaause the falling animation plays but I have no idea if that has anything to do with it…