repeat wait()until game:IsLoaded()wait(.01)local x=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local t=game.Players.LocalPlayer.Character.Humanoid local Z=TweenInfo.new(.325,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local o=TweenInfo.new(.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)local b={CameraOffset=Vector3.new(0,-1,0)}local V={CameraOffset=Vector3.new(0,0,0)}local y=script.Parent.Parent.R6Anims local j=script.Parent.Parent.R15Anims local v=x:Create(t,Z,b)local U=x:Create(t,o,V)local L=t:LoadAnimation(j.Idle)local z=t:LoadAnimation(j.Walk)if t.RigType==Enum.HumanoidRigType.R6 then L=t:LoadAnimation(y.Idle)z=t:LoadAnimation(y.Walk)elseif t.RigType==Enum.HumanoidRigType.R15 then L=t:LoadAnimation(j.Idle)z=t:LoadAnimation(j.Walk)end local c=false local p=false local function e()if p==false then if c==false then script.Parent.Parent.ImageColor3=script.Parent.Parent.Values.OnCrouchColor.Value script.Parent.Parent.CrouchImage.ImageColor3=Color3.new(1,1,1)t.WalkSpeed=8 p=true c=true L:Play()v:Play()t.Running:Connect(function(x)if c==true then if x>=1 then L:Stop()if z.IsPlaying==false then z:Play()end else L:Play()z:Stop()end end end)wait(.05)p=false else script.Parent.Parent.ImageColor3=script.Parent.Parent.Values.OriginalColor.Value script.Parent.Parent.CrouchImage.ImageColor3=Color3.new(0,0,0)t.WalkSpeed=16 p=true c=false L:Stop()z:Stop()U:Play()wait(.05)p=false end end end local h=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")h.InputBegan:Connect(function(x)if script.Parent.Parent.Visible==true then if x.KeyCode==Enum.KeyCode.C then e()end end end)script.Parent.Parent.MouseButton1Click:Connect(function()e()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, 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)
