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 Q=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local m=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local V=require(Q.ClientModules.Constants)local e=game.Players.LocalPlayer local B=e.Character or e.CharacterAdded:Wait()local d=B:WaitForChild("\072\117\109\097\110\111\105\100")local p=d:WaitForChild("\065\110\105\109\097\116\111\114")local X,Y=nil,nil local D,I=nil,nil IdleAnimation=p:LoadAnimation(Q.Animations.Idle)SprintAnimation=p:LoadAnimation(Q.Animations.Sprint)CrouchAnimation=p:LoadAnimation(Q.Animations.Crouch)local z=false local b=false local M=false local U=false local function L()if b then d.WalkSpeed=16 SprintAnimation:Stop()b=false end if z then d.WalkSpeed=16 CrouchAnimation:Stop()else if M then IdleAnimation:Play()end CrouchAnimation:Play()d.WalkSpeed=10 end z=not z end local function G()if z then d.WalkSpeed=16 CrouchAnimation:Stop()if M then IdleAnimation:Stop()end z=false end if b then d.WalkSpeed=16 if M then SprintAnimation:Stop()IdleAnimation:Play()end else if M then IdleAnimation:Stop()SprintAnimation:Play()end d.WalkSpeed=24 end b=not b end m.InputBegan:Connect(function(Q,m)if m then return end if Q.KeyCode==V.sprintKey and not U then G()elseif Q.KeyCode==V.crouchKey then L()elseif Q.KeyCode==Enum.KeyCode.Space then if z then L()end end end)B.ChildAdded:Connect(function(Q)if Q:IsA("\084\111\111\108")then M=true IdleAnimation:Play()if b then IdleAnimation:Stop()SprintAnimation:Play()end D=Q.Activated:Connect(function()if Q.GunType.Value~="\104\101\097\108"then U=true if b then d.WalkSpeed=16 b=false SprintAnimation:Stop()IdleAnimation:Play()end end end)I=Q.Deactivated:Connect(function()U=false end)end end)B.ChildRemoved:Connect(function(Q)if Q:IsA("\084\111\111\108")then M=false IdleAnimation:Stop()SprintAnimation:Stop()if D~=nil then D:Disconnect()I:Disconnect()end end end)
-- deltarager cried here
-- 27/05/2021

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)
