local Y=nil char.ChildAdded:connect(function(Q)if Q:IsA("\084\111\111\108")and(Humanoid.Health>0 and(not ToolEquip and(Q:FindFirstChild("\065\067\083\095\083\101\116\116\105\110\103\115")~=nil and((require(Q.ACS_Settings)).Type=="\071\117\110"or(require(Q.ACS_Settings)).Type=="\077\101\108\101\101"or(require(Q.ACS_Settings)).Type=="\071\114\101\110\097\100\101"))))then local c=true if(char:WaitForChild("\072\117\109\097\110\111\105\100")).Sit and char.Humanoid.SeatPart:IsA("\086\101\104\105\099\108\101\083\101\097\116")or(char:WaitForChild("\072\117\109\097\110\111\105\100")).Sit and char.Humanoid.SeatPart:IsA("\086\101\104\105\099\108\101\083\101\097\116")then c=false end if c then Y=Q if not ToolEquip then setup(Q)elseif ToolEquip then pcall(function()unset()setup(Q)end)end end end end)char.ChildRemoved:connect(function(Y)if Y==WeaponTool then if ToolEquip then unset()end end end)Humanoid.Running:Connect(function(Y)charspeed=Y if Y>.1 then running=true else running=false end end)Humanoid.Swimming:Connect(function(Y)if Swimming then charspeed=Y if Y>.1 then running=true else running=false end end end)Humanoid.Died:Connect(function(Y)(TS:Create(char.Humanoid,TweenInfo.new(1),{CameraOffset=Vector3.new(0,0,0)})):Play()ChangeStance=false Stand()Stances=0 Virar=0 CameraX=0 CameraY=0 Lean()Equipped=0 unset()Evt.NVG:Fire(false)end)Humanoid.Seated:Connect(function(Y,Q)if Y and(Q and Q:IsA("\086\101\104\105\099\108\101\083\101\097\116"))then unset()Humanoid:UnequipTools()CanLean=false plr.CameraMaxZoomDistance=gameRules.VehicleMaxZoom else plr.CameraMaxZoomDistance=game.StarterPlayer.CameraMaxZoomDistance end if Y then Sentado=true Stances=0 Virar=0 CameraX=0 CameraY=0 Stand()Lean()else Sentado=false CanLean=true end end)Humanoid.Changed:connect(function(Y)if gameRules.AntiBunnyHop then if Y=="\074\117\109\112"and(Humanoid.Sit==true and Humanoid.SeatPart~=nil)then Humanoid.Sit=false elseif Y=="\074\117\109\112"and Humanoid.Sit==false then if JumpDelay then Humanoid.Jump=false return false end JumpDelay=true delay(0,function()wait(gameRules.JumpCoolDown)JumpDelay=false end)end end end)Humanoid.StateChanged:connect(function(Y,Q)if Q==Enum.HumanoidStateType.Swimming then Swimming=true Stances=0 Virar=0 CameraX=0 CameraY=0 Stand()Lean()else Swimming=false end if gameRules.EnableFallDamage then if Q==Enum.HumanoidStateType.Freefall and not falling then falling=true local Y=0 local Q=0 while falling do Y=HumanoidRootPart.Velocity.magnitude Q=Q+1 Thread:Wait()end local c=(Y-gameRules.MaxVelocity)*gameRules.DamageMult if c>5 and Q>20 then local Y=SKP_01 ..("-"..plr.UserId)cameraspring:accelerate(Vector3.new(-c/20,0,math.random(-c,c)/5))SwaySpring:accelerate(Vector3.new(math.random(-c,c)/5,c/5,0))local Q=PastaFx.FallDamage:Clone()Q.Parent=plr.PlayerGui Q.Volume=c/Humanoid.MaxHealth Q:Play()Debris:AddItem(Q,Q.TimeLength)Evt.Damage:InvokeServer(nil,nil,nil,nil,nil,nil,true,c,Y)end elseif Q==Enum.HumanoidStateType.Landed or Q==Enum.HumanoidStateType.Dead then falling=false SwaySpring:accelerate(Vector3.new(0,2.5,0))end end end)mouse.WheelBackward:Connect(function()if ToolEquip and(not CheckingMag and(not aimming and(not reloading and(not runKeyDown and(AnimDebounce and WeaponData.Type=="\071\117\110")))))then mouse1down=false if GunStance==0 then SafeMode=true GunStance=-1 UpdateGui()Evt.GunStance:FireServer(GunStance,AnimData)LowReady()elseif GunStance==-1 then SafeMode=true GunStance=-2 UpdateGui()Evt.GunStance:FireServer(GunStance,AnimData)Patrol()elseif GunStance==1 then SafeMode=false GunStance=0 UpdateGui()Evt.GunStance:FireServer(GunStance,AnimData)IdleAnim()end end if ToolEquip and(aimming and Sens>5)then Sens=Sens-5 UpdateGui();(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseDeltaSensitivity=Sens/100 end end)mouse.WheelForward:Connect(function()if ToolEquip and(not CheckingMag and(not aimming and(not reloading and(not runKeyDown and(AnimDebounce and WeaponData.Type=="\071\117\110")))))then mouse1down=false if GunStance==0 then SafeMode=true GunStance=1 UpdateGui()Evt.GunStance:FireServer(GunStance,AnimData)HighReady()elseif GunStance==-1 then SafeMode=false GunStance=0 UpdateGui()Evt.GunStance:FireServer(GunStance,AnimData)IdleAnim()elseif GunStance==-2 then SafeMode=true GunStance=-1 UpdateGui()Evt.GunStance:FireServer(GunStance,AnimData)LowReady()end end if ToolEquip and(aimming and Sens<100)then Sens=Sens+5 UpdateGui();(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseDeltaSensitivity=Sens/100 end end);(script.Parent:GetAttributeChangedSignal("\073\110\106\117\114\101\100")):Connect(function()local Y=script.Parent:GetAttribute("\073\110\106\117\114\101\100")if Y and runKeyDown then runKeyDown=false Stand()if not CheckingMag and(not reloading and(WeaponData and(WeaponData.Type~="\071\114\101\110\097\100\101"and(GunStance==0 or GunStance==2 or GunStance==3))))then GunStance=0 Evt.GunStance:FireServer(GunStance,AnimData)IdleAnim()end end if Stances==0 then Stand()elseif Stances==1 then Crouch()end end)

local L_199_ = nil
char.ChildAdded:connect(function(Tool)
	if Tool:IsA('Tool') and Humanoid.Health > 0 and not ToolEquip and Tool:FindFirstChild("ACS_Settings") ~= nil and (require(Tool.ACS_Settings).Type == 'Gun' or require(Tool.ACS_Settings).Type == 'Melee' or require(Tool.ACS_Settings).Type == 'Grenade') then
		local L_370_ = true
		if char:WaitForChild('Humanoid').Sit and char.Humanoid.SeatPart:IsA("VehicleSeat") or char:WaitForChild('Humanoid').Sit and char.Humanoid.SeatPart:IsA("VehicleSeat") then
			L_370_ = false;
		end

		if L_370_ then
			L_199_ = Tool
			if not ToolEquip then
				--pcall(function()
				setup(Tool)
				--end)

			elseif ToolEquip then
				pcall(function()
					unset()
					setup(Tool)
				end)
			end;
		end;
	end

end)

char.ChildRemoved:connect(function(Tool)
	if Tool == WeaponTool then
		if ToolEquip then
			unset()
		end
	end
end)

Humanoid.Running:Connect(function(speed)
	charspeed = speed
	if speed > 0.1 then
		running = true
	else
		running = false
	end
end)

Humanoid.Swimming:Connect(function(speed)
	if Swimming then
		charspeed = speed
		if speed > 0.1 then
			running = true
		else
			running = false
		end
	end
end)

Humanoid.Died:Connect(function(speed)
	TS:Create(char.Humanoid, TweenInfo.new(1), {CameraOffset = Vector3.new(0,0,0)} ):Play()
	ChangeStance = false
	Stand()
	Stances = 0
	Virar = 0
	CameraX = 0
	CameraY = 0
	Lean()
	Equipped = 0
	unset()
	Evt.NVG:Fire(false)
end)

Humanoid.Seated:Connect(function(IsSeated, Seat)

	if IsSeated and Seat and (Seat:IsA("VehicleSeat")) then
		unset()
		Humanoid:UnequipTools()
		CanLean = false
		plr.CameraMaxZoomDistance = gameRules.VehicleMaxZoom
	else
		plr.CameraMaxZoomDistance = game.StarterPlayer.CameraMaxZoomDistance
	end

	if IsSeated  then
		Sentado = true
		Stances = 0
		Virar = 0
		CameraX = 0
		CameraY = 0
		Stand()
		Lean()
	else
		Sentado = false
		CanLean = true
	end
end)

Humanoid.Changed:connect(function(Property)
	if gameRules.AntiBunnyHop then
		if Property == "Jump" and Humanoid.Sit == true and Humanoid.SeatPart ~= nil then
			Humanoid.Sit = false
		elseif Property == "Jump" and Humanoid.Sit == false then
			if JumpDelay then
				Humanoid.Jump = false
				return false
			end
			JumpDelay = true
			delay(0, function()
				wait(gameRules.JumpCoolDown)
				JumpDelay = false
			end)
		end
	end
end)

Humanoid.StateChanged:connect(function(Old,state)
	if state == Enum.HumanoidStateType.Swimming then
		Swimming = true
		Stances = 0
		Virar = 0
		CameraX = 0
		CameraY = 0
		Stand()
		Lean()
	else
		Swimming = false
	end

	if gameRules.EnableFallDamage then
		if state == Enum.HumanoidStateType.Freefall and not falling then
			falling = true
			local curVel = 0
			local peak = 0

			while falling do
				curVel = HumanoidRootPart.Velocity.magnitude
				peak = peak + 1
				Thread:Wait()
			end
			local damage = (curVel - (gameRules.MaxVelocity)) * gameRules.DamageMult
			if damage > 5 and peak > 20 then
				local SKP_02 = SKP_01.."-"..plr.UserId

				cameraspring:accelerate(Vector3.new(-damage/20, 0, math.random(-damage, damage)/5))
				SwaySpring:accelerate(Vector3.new( math.random(-damage, damage)/5, damage/5,0))

				local hurtSound = PastaFx.FallDamage:Clone()
				hurtSound.Parent = plr.PlayerGui
				hurtSound.Volume = damage/Humanoid.MaxHealth
				hurtSound:Play()
				Debris:AddItem(hurtSound,hurtSound.TimeLength)

				Evt.Damage:InvokeServer(nil, nil, nil, nil, nil, nil, true, damage, SKP_02)

			end
		elseif state == Enum.HumanoidStateType.Landed or state == Enum.HumanoidStateType.Dead then
			falling = false
			SwaySpring:accelerate(Vector3.new(0, 2.5, 0))
		end
	end

end)

mouse.WheelBackward:Connect(function() -- fires when the wheel goes forwards

	if ToolEquip and not CheckingMag and not aimming and not reloading and not runKeyDown and AnimDebounce and WeaponData.Type == "Gun" then
		mouse1down = false
		if GunStance == 0 then
			SafeMode = true
			GunStance = -1
			UpdateGui()
			Evt.GunStance:FireServer(GunStance,AnimData)
			LowReady()
		elseif GunStance == -1 then
			SafeMode = true
			GunStance = -2
			UpdateGui()
			Evt.GunStance:FireServer(GunStance,AnimData)
			Patrol()
		elseif GunStance == 1 then
			SafeMode = false
			GunStance = 0
			UpdateGui()
			Evt.GunStance:FireServer(GunStance,AnimData)
			IdleAnim()
		end
	end

	if ToolEquip and aimming and Sens > 5 then
		Sens = Sens - 5
		UpdateGui()
		game:GetService('UserInputService').MouseDeltaSensitivity = (Sens/100)
	end

end)


mouse.WheelForward:Connect(function() -- fires when the wheel goes backwards

	if ToolEquip and not CheckingMag and not aimming and not reloading and not runKeyDown and AnimDebounce and WeaponData.Type == "Gun" then
		mouse1down = false
		if GunStance == 0 then
			SafeMode = true
			GunStance = 1
			UpdateGui()
			Evt.GunStance:FireServer(GunStance,AnimData)
			HighReady()
		elseif GunStance == -1 then
			SafeMode = false
			GunStance = 0
			UpdateGui()
			Evt.GunStance:FireServer(GunStance,AnimData)
			IdleAnim()
		elseif GunStance == -2 then
			SafeMode = true
			GunStance = -1
			UpdateGui()
			Evt.GunStance:FireServer(GunStance,AnimData)
			LowReady()
		end
	end

	if ToolEquip and aimming and Sens < 100 then
		Sens = Sens + 5
		UpdateGui()
		game:GetService('UserInputService').MouseDeltaSensitivity = (Sens/100)
	end

end)

script.Parent:GetAttributeChangedSignal("Injured"):Connect(function()
	local valor = script.Parent:GetAttribute("Injured")

	if valor and runKeyDown then
		runKeyDown 	= false
		Stand()
		if not CheckingMag and not reloading and WeaponData and WeaponData.Type ~= "Grenade" and (GunStance == 0 or GunStance == 2 or GunStance == 3) then
			GunStance = 0
			Evt.GunStance:FireServer(GunStance,AnimData)
			IdleAnim()
		end
	end

	if Stances == 0 then
		Stand()
	elseif Stances == 1 then
		Crouch()
	end

end)
