So for some reason, this crouch script does not work, My script dev says its buggy for some reason and makes you go free falling state when you try to come out of crouch. How could this be fixed?
wait(0.5) --Wait time
on = 0
Tool = game.Players.LocalPlayer.Character
welds = {}
sh = {}
arms = nil
torso = nil
local mouse
f = nil
function Crouch(ison)
if arms == nil and torso == nil then
arms = {Tool:FindFirstChild("Left Leg"), Tool:FindFirstChild("Right Leg")}
torso = Tool:FindFirstChild("Torso")
end
if arms ~= nil and torso ~= nil then
sh = {torso:FindFirstChild("Left Hip"), torso:FindFirstChild("Right Hip")}
if sh ~= nil then
local yes = true
if yes then
yes = false
if ison == 1 then--if on
sh[1].Part1 = nil
sh[2].Part1 = nil
local weld1 = Instance.new("Weld")--weld1
weld1.Part0 = torso
weld1.Parent = torso
weld1.Part1 = arms[1]
weld1.C1 = CFrame.new(-0.5, 0.75, 1)
arms[1].Name = "LDave"
arms[1].CanCollide = true
welds[1] = weld1
local weld2 = Instance.new("Weld")--weld2
weld2.Part0 = torso
weld2.Parent = torso
weld2.Part1 = arms[2]
weld2.C1 = CFrame.new(0.5,0.495,1.25) * CFrame.fromEulerAnglesXYZ(math.rad(90),0,0)
arms[2].Name = "RDave"
arms[2].CanCollide = true
welds[2] = weld2
local force = Instance.new("BodyForce")
force.Parent = torso
f = force
wait(0.01)
elseif ison == 0 then
if arms then
sh[1].Part1 = arms[1]
sh[2].Part1 = arms[2]
f.Parent = nil
arms[2].Name = "Right Leg"
arms[1].Name = "Left Leg"
welds[1].Parent = nil
welds[2].Parent = nil
end
end
end
else
print("sh")
end
else
print("leg") --if leg missing
end
end
function Key(key)
if key then
key = string.lower(key)
if (key=="c") then
if on == 1 then
on = 0
elseif on == 0 then
on = 1
end
Crouch(on)
end
end
end
mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(Key)
