repeat wait()until game:IsLoaded()wait(.01)local u=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local c=game.Players.LocalPlayer.Character.Humanoid local I=TweenInfo.new(.325,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local F=TweenInfo.new(.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local S={CameraOffset=Vector3.new(0,-1,0)}local Q={CameraOffset=Vector3.new(0,0,0)}local l=script.Parent.Parent.R6Anims local W=script.Parent.Parent.R15Anims local m=u:Create(c,I,S)local s=u:Create(c,F,Q)local w=c:LoadAnimation(W.Idle)local K=c:LoadAnimation(W.Walk)if c.RigType==Enum.HumanoidRigType.R6 then w=c:LoadAnimation(l.Idle)K=c:LoadAnimation(l.Walk)elseif c.RigType==Enum.HumanoidRigType.R15 then w=c:LoadAnimation(W.Idle)K=c:LoadAnimation(W.Walk)end local G=false local A=false local function M()if A==false then if G==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 A=true G=true w:Play()m:Play()c.Running:Connect(function(u)if G==true then if u>=1 then w:Stop()if K.IsPlaying==false then K:Play()end else w:Play()K:Stop()end end end)wait(.05)A=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 A=true G=false w:Stop()K:Stop()s:Play()wait(.05)A=false end end end local P=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")P.InputBegan:Connect(function(u)if script.Parent.Parent.Visible==true then if u.KeyCode==Enum.KeyCode.C then M()end end end)script.Parent.Parent.MouseButton1Click:Connect(function()M()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,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.C then
			Crouch()
		end
	end
end)
script.Parent.Parent.MouseButton1Click:Connect(function()
	Crouch()
end)

