repeat wait()until game:IsLoaded()wait(.01)local i=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local c=game.Players.LocalPlayer.Character.Humanoid local K=TweenInfo.new(.325,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local J=TweenInfo.new(.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local Q={CameraOffset=Vector3.new(0,-1.75,0)}local o={CameraOffset=Vector3.new(0,0,0)}local D=script.Parent.Parent.R6Anims local g=script.Parent.Parent.R15Anims local B=i:Create(c,K,Q)local X=i:Create(c,J,o)local V=c:LoadAnimation(g.Idle)local n=c:LoadAnimation(g.Walk)if c.RigType==Enum.HumanoidRigType.R6 then V=c:LoadAnimation(D.Idle)n=c:LoadAnimation(D.Walk)elseif c.RigType==Enum.HumanoidRigType.R15 then V=c:LoadAnimation(g.Idle)n=c:LoadAnimation(g.Walk)end local F=false local H=false local function e()if H==false then if F==false then script.Parent.Parent.ImageColor3=script.Parent.Parent.Values.OnCrouchColor.Value script.Parent.Parent.CrouchImage.ImageColor3=Color3.new(1,1,1)c.WalkSpeed=8 H=true F=true V:Play()B:Play()c.Running:Connect(function(i)if F==true then if i>=1 then V:Stop()if n.IsPlaying==false then n:Play()end else V:Play()n:Stop()end end end)wait(.05)H=false else script.Parent.Parent.ImageColor3=script.Parent.Parent.Values.OriginalColor.Value script.Parent.Parent.CrouchImage.ImageColor3=Color3.new(0,0,0)c.WalkSpeed=16 H=true F=false V:Stop()n:Stop()X:Play()wait(.05)H=false end end end local z=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")z.InputBegan:Connect(function(i)if script.Parent.Parent.Visible==true then if i.KeyCode==Enum.KeyCode.LeftControl then e()end end end)script.Parent.Parent.MouseButton1Click:Connect(function()e()end)


repeat wait() until game:IsLoaded()
wait(0.01)
local TweenService = game:GetService("TweenService") 
local tweenPart = game.Players.LocalPlayer.Character.Humanoid 

local info = TweenInfo.new(
	0.325,          
	Enum.EasingStyle.Back,  
	Enum.EasingDirection.Out,  
	0,                
	false,         
	0             
)
local info2 = TweenInfo.new(
	0.3,   
	Enum.EasingStyle.Back,   
	Enum.EasingDirection.Out,  
	0,               
	false,              
	0               
)

local Goals = {CameraOffset = Vector3.new(0,-1.75,0)}
local Goals2 = {CameraOffset = Vector3.new(0,0,0)}

local animsR6 = script.Parent.Parent.R6Anims
local animsR15 = script.Parent.Parent.R15Anims

local PartTween = TweenService:Create(tweenPart, info, Goals)
local PartTween2 = TweenService:Create(tweenPart, info2, Goals2)

local animidle = tweenPart:LoadAnimation(animsR15.Idle)
local animwalk = tweenPart:LoadAnimation(animsR15.Walk)

if tweenPart.RigType == Enum.HumanoidRigType.R6 then
	animidle = tweenPart:LoadAnimation(animsR6.Idle)
	animwalk = tweenPart:LoadAnimation(animsR6.Walk)
elseif tweenPart.RigType == Enum.HumanoidRigType.R15 then
	animidle = tweenPart:LoadAnimation(animsR15.Idle)
	animwalk = tweenPart:LoadAnimation(animsR15.Walk)
end

local crouching = false
local waiting = false

local function Crouch()
	if waiting == false then
		if crouching == false then
			script.Parent.Parent.ImageColor3 = script.Parent.Parent.Values.OnCrouchColor.Value
			script.Parent.Parent.CrouchImage.ImageColor3 = Color3.new(1, 1, 1)
			tweenPart.WalkSpeed = 8
			waiting = true
			crouching = true
			animidle:Play()
			PartTween:Play() --plays it
			tweenPart.Running:Connect(function(Speed)
				if crouching == true then
					if Speed >= 1 then
						animidle:Stop()
						if animwalk.IsPlaying == false then
							animwalk:Play()
						end

					else
						animidle:Play()
						animwalk:Stop()
					end
				end
			end)
			wait(0.05)
			waiting = false
		else
			script.Parent.Parent.ImageColor3 = script.Parent.Parent.Values.OriginalColor.Value
			script.Parent.Parent.CrouchImage.ImageColor3 = Color3.new(0, 0, 0)
			tweenPart.WalkSpeed = 16
			waiting = true
			crouching = false
			animidle:Stop()
			animwalk:Stop()
			PartTween2:Play()
			wait(0.05)
			waiting = false
		end
	end
end
local userinputservice = game:GetService("UserInputService")
userinputservice.InputBegan:Connect(function(input)
	if script.Parent.Parent.Visible == true then
		if input.KeyCode == Enum.KeyCode.LeftControl then
			Crouch()
		end
	end
end)
script.Parent.Parent.MouseButton1Click:Connect(function()
	Crouch()
end)

