client:
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")

local ClientSettings = ReplicatedStorage.ClientSettings
local CameraSettings = ClientSettings.Camera
local Animations = ReplicatedStorage.Animations
local Modules = ReplicatedStorage.Modules
local Particles = ReplicatedStorage.Resources.Particles

local CameraShaker = require(Modules.CameraShaker)

local Camera = workspace.CurrentCamera
local GameSettings = workspace.GameSettings
local Peforms = script.Peforms

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")

local PlayerGui = Player.PlayerGui
local Sounds = PlayerGui.SOUNDS

local CanSlide = false
local Ending = false
local SlideAmount = 0
local Vector = Instance.new("NumberValue")

local SlideAnimation = Character.Humanoid:LoadAnimation(Animations.Movement.SlideAnimation)
local GetUpAnimation = Character.Humanoid:LoadAnimation(Animations.Movement.GetUpAnimation)
local RunAnimation = Character.Humanoid:LoadAnimation(Animations.Movement.RunAnim)

local sprinting = false
local Data = Character:WaitForChild("Data")
local Values = Character:WaitForChild("Values")
local Settings = Character:WaitForChild("Settings")
local stamina = Data.Stamina
local maxStamina = 100
local staminaDepletionRate = 0.3
local staminaRecoveryRate = 0.1
local Count = 0

local CameraSubject = Instance.new("Part")
CameraSubject.Name = "CameraSubject"
CameraSubject.Transparency = 1
CameraSubject.Massless = true
CameraSubject.CanTouch = false
CameraSubject.CanCollide = false
CameraSubject.Parent = Player.Character

local Weld = Instance.new("Weld")
Weld.Name = "CameraWeld"
Weld.Part0 = CameraSubject
Weld.Part1 = Player.Character.Torso
Weld.Parent = Player.Character.Head

local function EndSlide()
	if Ending then return end
	if CanSlide == true then
		Ending = true
		CanSlide = false
		SlideAmount = 0
		SlideAnimation:Stop(0.5)
		GetUpAnimation:Play()
		Humanoid.HipHeight = 0
		Humanoid.WalkSpeed = 0
		GetUpAnimation.Stopped:Connect(function()
			Ending = false
			Humanoid.WalkSpeed = 16
		end)
	end
end

local function Slide()
	if Ending or stamina.Value < 25 or Settings.Ragdoll.Value or Settings.Downed.Value then return end
	SlideAnimation:Play(0.1)
	Humanoid.JumpHeight = 0
	Humanoid.HipHeight = -1.4
	Humanoid.WalkSpeed = 0
	Vector.Value = 1
	local Tween = TweenService:Create(Vector, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Value = 10})
	Tween:Play()
	task.wait(0.08)
	CanSlide = true
	Tween.Completed:Connect(function()
		task.wait(2)
		TweenService:Create(Vector, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Value = 0}):Play()
	end)
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.MaxForce = Vector3.new(1, 0, 1) * 30000
	BodyVelocity.Velocity = RootPart.CFrame.lookVector * 5
	BodyVelocity.Parent = RootPart
	task.wait(0.8)
	Debris:AddItem(BodyVelocity, 0.1)
end

local function Running(speed)
	if speed > 0.1 and CanSlide then
		if Character.Values.Locked.Value == false then
			TweenService:Create(Camera, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {FieldOfView = CameraSettings.FOV.Value - 10}):Play()
		end
		for _, leg in {"Left Leg", "Right Leg"} do
			local legObj = Character[leg]
			if legObj then
				local SprintParticle = legObj:FindFirstChild("Sprint")
				if SprintParticle then
					SprintParticle.Enabled = true
				end
			end
		end
	else
		if Character.Values.Locked.Value == false then
			TweenService:Create(Camera, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {FieldOfView = CameraSettings.FOV.Value}):Play()
		end
		for _, leg in {"Left Leg", "Right Leg"} do
			local legObj = Character[leg]
			if legObj then
				local SprintParticle = legObj:FindFirstChild("Sprint")
				if SprintParticle then
					SprintParticle.Enabled = false
				end
			end
		end
	end
end

local function SlideRender()
	if CanSlide and not Character.Values.Locked.Value then
		local EndPosition = RootPart.Position + RootPart.CFrame.LookVector * Vector.Value
		local BodyPosition = Instance.new("BodyPosition")
		BodyPosition.Position = EndPosition
		BodyPosition.MaxForce = Vector3.new(100000, 100000, 100000)
		BodyPosition.Parent = RootPart
		task.wait(0)
		Debris:AddItem(BodyPosition, 0)
	end
end

local function SprintBegin()
	if GameSettings.GameStatus.Value == "Ended" or stamina.Value == 0 or stamina.Value < 25 or Settings.Ragdoll.Value or Settings.Downed.Value then
		return
	end
	Humanoid.WalkSpeed = 26
	stamina:GetPropertyChangedSignal("Value"):Connect(function()
		if stamina.Value == 0 or Ending then
			RunAnimation:Stop(0.3)
			Humanoid.WalkSpeed = 16
			sprinting = false
		end
	end)
	sprinting = true
end

local function SprintStop()
	if GameSettings.GameStatus.Value == "Ended" then
		return
	end
	RunAnimation:Stop(0.3)
	Humanoid.WalkSpeed = 16
	sprinting = false
end

Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
	if GameSettings.GameStatus.Value == "Ended" or Ending or Values.Locked.Value then
		return
	end
	Humanoid.WalkSpeed = sprinting and 26 or 16
end)

local AbilityEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Ability")
local AbilityKeybind = "Q"

UserInputService.InputBegan:Connect(function(input,Chatting)
	if Chatting then return end
	if input.KeyCode == Enum.KeyCode[AbilityKeybind] then -- Q is the default ability keybind
		AbilityEvent:FireServer()
	end
end)

RunService.Stepped:Connect(function()
	if GameSettings.GameStatus.Value == "Ended" or Character.Values.Locked.Value then
		if Humanoid.Health <= 30 and Humanoid.Health > 15 then
			Character.Humanoid.WalkSpeed = 4
			Character.Humanoid.JumpPower = 0
		elseif Humanoid.Health <= 15 and Humanoid.Health > 0 then
			Character.Humanoid.WalkSpeed = 3
			Character.Humanoid.JumpPower = 0
		elseif Values.Reviving.Value then
			Character.Humanoid.WalkSpeed = 0
			Character.Humanoid.JumpPower = 0
		end
	end
	if sprinting or CanSlide then
		stamina.Value = math.max(stamina.Value - staminaDepletionRate, 0)
		if stamina.Value == 0 then
			Humanoid.WalkSpeed = 0
			sprinting = false
		end
	else
		if Settings.Ragdoll.Value or Settings.Downed.Value then return end
		stamina.Value = math.min(stamina.Value + staminaRecoveryRate, maxStamina)
	end
end)

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and stamina.Value > 0 and stamina.Value >= maxStamina * 0.2 and not Character.Values.Locked.Value and not Settings.Ragdoll.Value and not Settings.Downed.Value then
		if Humanoid.MoveDirection.magnitude > 0 then
			SprintBegin()
			sprinting = true
			RunAnimation:Play(0.6)
		end
	end
	if input.KeyCode == Enum.KeyCode.V and sprinting and not Values.Locked.Value then
		Slide()
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and not Values.Locked.Value then
		SprintStop()
	end
	if input.KeyCode == Enum.KeyCode.V and not Values.Locked.Value then
		EndSlide()
	end
end)

Character:WaitForChild("Head").DescendantAdded:Connect(function(Object)
	if Object.Name == "InformationUI" or Object.Name == "EnemyUI" then
		Object.AlwaysOnTop = true
	end
end)

local function IncrementSlideAmount()
	if CanSlide == true then
		SlideAmount = SlideAmount + 0.1
	end
end

Vector:GetPropertyChangedSignal("Value"):Connect(function()
	if Ending then return end
	if SlideAmount >= 3 or stamina.Value <= 25 then
		EndSlide()
	end
end)

Values.Locked:GetPropertyChangedSignal("Value"):Connect(function()
	if Values.Locked.Value then
		CanSlide = false
		sprinting = false
		SprintStop()
	end
end)

Peforms.ZoomOut:GetPropertyChangedSignal("Value"):Connect(function()
	if Peforms.ZoomOut.Value then
		TweenService:Create(Camera, TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {FieldOfView = 80}):Play()
		task.wait(0.8)
		TweenService:Create(Camera, TweenInfo.new(1.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {FieldOfView = 50}):Play()
	end
end)

Peforms.ScreenActive:GetPropertyChangedSignal("Value"):Connect(function()
	if Peforms.ScreenActive.Value == false then return end
	local Camera = workspace.CurrentCamera
	--Camera:ClearAllChildren()

	if Peforms.ScreenColor.Value == "Fire" then
		local Filter = Instance.new("ColorCorrectionEffect")
		Filter.Brightness = 0.4
		Filter.TintColor = Color3.fromRGB(255, 85, 0)
		Filter.Parent = Camera
		Debris:AddItem(Filter, 5)
		TweenService:Create(Filter, TweenInfo.new(3, Enum.EasingStyle.Quint), {TintColor = Color3.fromRGB(255, 255, 255), Brightness = 0}):Play()
	elseif Peforms.ScreenColor.Value == "White" then
		local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
			Camera.CFrame = Camera.CFrame * shakeCFrame
		end)

		if Count == 0 then
			if Count == 1 then return end
			camShake:Start()
			camShake:StartShake(2, 0.3, 2, 6)
			Count = 1
		end

		local Filter = Instance.new("ColorCorrectionEffect")
		Filter.Brightness = 0.06
		Filter.TintColor = Color3.fromRGB(255, 255, 255)
		Filter.Parent = Camera
		Debris:AddItem(Filter, 5)
		TweenService:Create(Filter, TweenInfo.new(1, Enum.EasingStyle.Sine), {TintColor = Color3.fromRGB(255, 255, 255), Brightness = 0}):Play()
		task.wait(0.8)
		CameraShaker.Stop(camShake)
		camShake:Stop()    
		Count = 0
	elseif Peforms.ScreenColor.Value == "Red" then
		local Filter = Instance.new("ColorCorrectionEffect")
		Filter.Brightness = 0.4
		Filter.TintColor = Color3.fromRGB(85, 0, 0)
		Filter.Parent = Camera
		Debris:AddItem(Filter, 5)
		TweenService:Create(Filter, TweenInfo.new(3, Enum.EasingStyle.Quint), {TintColor = Color3.fromRGB(255, 255, 255), Brightness = 0}):Play()
	elseif Peforms.ScreenColor.Value == "Gray" then
		local camShakeG = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
			Camera.CFrame = Camera.CFrame * shakeCFrame
		end)
		if Count == 0 then
			Count = 1
			camShakeG:Start()
			camShakeG:StartShake(3, 1, 5, 7)
		end
		Sounds.Bass:Play()
		TweenService:Create(Camera, TweenInfo.new(1.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {FieldOfView = 30}):Play()
		TweenService:Create(game.Lighting.ColorCorrection, TweenInfo.new(1, Enum.EasingStyle.Sine), {Saturation = -1}):Play()
		task.wait(4.5)
		TweenService:Create(game.Lighting.ColorCorrection, TweenInfo.new(1, Enum.EasingStyle.Sine), {Saturation = -0.03}):Play()
		camShakeG:Stop()
		Count = 0
	end
end)

local function AddMovementParticles()
	for _, MovementParticle in Particles.Movement:GetChildren() do
		local Particle = MovementParticle:Clone()
		Particle.Parent = Character["Left Leg"]
		Particle = MovementParticle:Clone()
		Particle.Parent = Character["Right Leg"]
	end
end

local function Infection()
	if GameSettings.Humans:FindFirstChild(Player.Name) then
		local UI = PlayerGui.UI
		local Screen = PlayerGui.UI.Visual.WhiteFlash
		Screen.BackgroundColor3 = Color3.fromRGB(0,0,0)
		Screen.BackgroundTransparency = 0
		UI.Gameplay.Backpack.Visible = false
		script.Sounds["Off"]:Play()
		ReplicatedStorage.LocalRemotes.Transform:FireServer()
	end
end

Character:WaitForChild("Humanoid").Died:Connect(function()
	Infection()
	task.wait(1)
	script:Destroy()
end)

Humanoid.Running:Connect(Running)
RunService.RenderStepped:Connect(SlideRender)

AddMovementParticles()

while task.wait(0.03) do
	IncrementSlideAmount()
end


--[[	for _, track in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do
		--print(track.Animation.AnimationId)
		if track.Animation.AnimationId == Animations.Movement.RunAnim.AnimationId then
			track:Stop()
			print("Stopped Animation")
		end
	end--]]

crouch snippet;
local crouchKey = Enum.KeyCode.C
local crouchSpeed = 8
local normalSpeed = 16
local crouchHeight = 1.5
local normalHeight = 2

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local crouchIdleAnimation = humanoid:LoadAnimation(script.CrouchIdle)
local crouchWalkAnimation = humanoid:LoadAnimation(script.CrouchWalk)

local isCrouching = false
local isMoving = false

function tweenAnimation(animation)
	animation:AdjustSpeed(1)
	animation:AdjustWeight(1)
end

local function crouch()
	isCrouching = true
	humanoid.WalkSpeed = crouchSpeed
	humanoidRootPart.Size = Vector3.new(humanoidRootPart.Size.X, crouchHeight, humanoidRootPart.Size.Z)
	if isMoving then
		crouchIdleAnimation:Stop() -- Stop crouch idle animation
		tweenAnimation(crouchWalkAnimation)
		crouchWalkAnimation:Play() -- Play crouch walk animation
	else
		crouchWalkAnimation:Stop() -- Stop crouch walk animation
		tweenAnimation(crouchIdleAnimation)
		crouchIdleAnimation:Play() -- Play crouch idle animation
	end
end

local function stand()
	isCrouching = false
	humanoid.WalkSpeed = normalSpeed
	humanoidRootPart.Size = Vector3.new(humanoidRootPart.Size.X, normalHeight, humanoidRootPart.Size.Z)
	crouchIdleAnimation:Stop()
	crouchWalkAnimation:Stop()
end

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if humanoid.MoveDirection.Magnitude > 0 then
		isMoving = true
		if isCrouching then
			crouchIdleAnimation:Stop()
			if not crouchWalkAnimation.IsPlaying then
				crouchWalkAnimation:Play()
			end
		end
	else
		isMoving = false
		if isCrouching then
			crouchWalkAnimation:Stop()
			if not crouchIdleAnimation.IsPlaying then
				crouchIdleAnimation:Play()
			end
		end
	end
end)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == crouchKey and not isCrouching then
		crouch()
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == crouchKey and isCrouching then
		stand()
	end
end)


add the crouch snippet to the main script.