repeat wait()until game:IsLoaded()wait(.01)local Z=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local N=game.Players.LocalPlayer.Character.Humanoid local Q=TweenInfo.new(.325,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local B=TweenInfo.new(.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local Y={CameraOffset=Vector3.new(0,-1.75,0)}local M={CameraOffset=Vector3.new(0,0,0)}local A=script.Parent.Parent.R6Anims local D=script.Parent.Parent.R15Anims local f=Z:Create(N,Q,Y)local L=Z:Create(N,B,M)local C=N:LoadAnimation(D.Idle)local V=N:LoadAnimation(D.Walk)if N.RigType==Enum.HumanoidRigType.R6 then C=N:LoadAnimation(A.Idle)V=N:LoadAnimation(A.Walk)elseif N.RigType==Enum.HumanoidRigType.R15 then C=N:LoadAnimation(D.Idle)V=N:LoadAnimation(D.Walk)end local n=false local O=false local function p()if O==false then if n==false then script.Parent.Parent.ImageColor3=script.Parent.Parent.Values.OnCrouchColor.Value script.Parent.Parent.CrouchImage.ImageColor3=Color3.new(1,1,1)N.WalkSpeed=8 O=true n=true C:Play()f:Play()N.Running:Connect(function(Z)if n==true then if Z>=1 then C:Stop()if V.IsPlaying==false then V:Play()end else C:Play()V:Stop()end end end)wait(.05)O=false else script.Parent.Parent.ImageColor3=script.Parent.Parent.Values.OriginalColor.Value script.Parent.Parent.CrouchImage.ImageColor3=Color3.new(0,0,0)N.WalkSpeed=16 O=true n=false C:Stop()V:Stop()L:Play()wait(.05)O=false end end end local T=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")T.InputBegan:Connect(function(Z)if script.Parent.Parent.Visible==true then if Z.KeyCode==Enum.KeyCode.LeftControl then p()end end end)script.Parent.Parent.MouseButton1Click:Connect(function()p()end)
--NOTE
--The animation can bug out, im still trying to find a way to fix that.

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)
