repeat wait()until game:IsLoaded()and(game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)~=nil and game.Players.LocalPlayer.Character:FindFirstChild("\072\117\109\097\110\111\105\100")~=nil)local G=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local z=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local o=require(G.ClientModules.Constants)local a=game.Players.LocalPlayer local C=a.Character or a.CharacterAdded:Wait()local E=C:WaitForChild("\072\117\109\097\110\111\105\100")local c=E:WaitForChild("\065\110\105\109\097\116\111\114")local j,i=nil,nil local r,M=nil,nil IdleAnimation=c:LoadAnimation(G.Animations.Idle)SprintAnimation=c:LoadAnimation(G.Animations.Sprint)CrouchAnimation=c:LoadAnimation(G.Animations.Crouch)local b=false local f=false local X=false local m=false local function A()if f then E.WalkSpeed=16 SprintAnimation:Stop()f=false end if b then E.WalkSpeed=16 CrouchAnimation:Stop()else if X then IdleAnimation:Play()end CrouchAnimation:Play()E.WalkSpeed=10 end b=not b end local function L()if b then E.WalkSpeed=16 CrouchAnimation:Stop()if X then IdleAnimation:Stop()end b=false end if f then E.WalkSpeed=16 if X then SprintAnimation:Stop()IdleAnimation:Play()end else if X then IdleAnimation:Stop()SprintAnimation:Play()end E.WalkSpeed=24 end f=not f end z.InputBegan:Connect(function(G,z)if z then return end if G.KeyCode==o.sprintKey and not m then L()elseif G.KeyCode==o.crouchKey then A()elseif G.KeyCode==Enum.KeyCode.Space then if b then A()end end end)C.ChildAdded:Connect(function(G)if G:IsA("\084\111\111\108")then X=true IdleAnimation:Play()if f then IdleAnimation:Stop()SprintAnimation:Play()end r=G.Activated:Connect(function()if G.GunType.Value~="\104\101\097\108"then m=true if f then E.WalkSpeed=16 f=false SprintAnimation:Stop()IdleAnimation:Play()end end end)M=G.Deactivated:Connect(function()m=false end)end end)C.ChildRemoved:Connect(function(G)if G:IsA("\084\111\111\108")then X=false IdleAnimation:Stop()SprintAnimation:Stop()if r~=nil then r:Disconnect()M:Disconnect()end end end)


repeat wait() until game:IsLoaded() and game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name) ~= nil and game.Players.LocalPlayer.Character:FindFirstChild("Humanoid") ~= nil

local ReplicatedStorage	= game:GetService("ReplicatedStorage")
local UserInputService	= game:GetService("UserInputService")
local constants			= require(ReplicatedStorage["ClientModules"].Constants)

local player	= game.Players.LocalPlayer
local character	= player.Character or player.CharacterAdded:Wait()
local humanoid	= character:WaitForChild("Humanoid")
local animator	= humanoid:WaitForChild("Animator")
local oldEvent1,oldEvent2	= nil,nil
local toolEvent,toolEventDe	= nil,nil

IdleAnimation 	= animator:LoadAnimation(ReplicatedStorage.Animations.Idle)
SprintAnimation = animator:LoadAnimation(ReplicatedStorage.Animations.Sprint)
CrouchAnimation = animator:LoadAnimation(ReplicatedStorage.Animations.Crouch)

local crouching	= false
local sprinting	= false
local equipped	= false
local shooting	= false

local function Crouch()
	if sprinting then
		humanoid.WalkSpeed = 16;
		SprintAnimation:Stop()
		sprinting = false
	end
	if crouching then
		humanoid.WalkSpeed = 16
		CrouchAnimation:Stop()
	else
		if equipped then
			IdleAnimation:Play()
		end
		CrouchAnimation:Play()
		humanoid.WalkSpeed = 10
	end
	crouching	= not crouching
end

local function Sprint()
	if crouching then
		humanoid.WalkSpeed = 16
		CrouchAnimation:Stop()
		if equipped then
			IdleAnimation:Stop()
		end
		crouching = false
	end
	if sprinting then
		humanoid.WalkSpeed = 16;
		if equipped then
			SprintAnimation:Stop()
			IdleAnimation:Play()
		end
	else
		if equipped then
			IdleAnimation:Stop()
			SprintAnimation:Play()
		end
		humanoid.WalkSpeed = 24;
	end
	sprinting		= not sprinting
end


UserInputService.InputBegan:Connect(function(input,gpe)
	if gpe then return end
	if input.KeyCode == constants.sprintKey and not shooting then
		Sprint()
	elseif input.KeyCode == constants.crouchKey then
		Crouch()
	elseif input.KeyCode == Enum.KeyCode.Space then
		if crouching then
			Crouch()
		end
	end 
end)

character.ChildAdded:Connect(function(child)
	if child:IsA("Tool") then
		equipped	= true
		IdleAnimation:Play()
		if sprinting then
			IdleAnimation:Stop()
			SprintAnimation:Play()
		end
		toolEvent		= child.Activated:Connect(function()
			if child.GunType.Value ~= "heal" then
				shooting 	= true
				if sprinting then
					humanoid.WalkSpeed = 16;
					sprinting = false
					SprintAnimation:Stop()
					IdleAnimation:Play()
				end
			end
		end)
		toolEventDe	 	= child.Deactivated:Connect(function()
			shooting 	= false
		end)
	end
end)
character.ChildRemoved:Connect(function(child)
	if child:IsA("Tool") then
		equipped	= false
		IdleAnimation:Stop()
		SprintAnimation:Stop()
		
		if toolEvent ~= nil then
			toolEvent:Disconnect()
			toolEventDe:Disconnect()
		end
	end
end)


