--[[						TS:Create(ArmaClone.REG, TweenInfo.new(0), {Transparency = 1}):Play()
							if ArmaClone:FindFirstChild("REG2") then
								TS:Create(ArmaClone.REG2, TweenInfo.new(0), {Transparency = 1}):Play()
							end
							TS:Create(ArmaClone.ADS, TweenInfo.new(0), {Transparency = 0}):Play()
]]
							
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end
								end
							end


						else
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end
								end
							end
						end
					elseif AimPartMode == 2 then
						tweenFoV(Settings.ChangeFOV[2],120)
						if Settings.FocusOnSight2 then
							--TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.75),{ImageTransparency = 0}):Play()
							TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = Settings.Focus2Distance}):Play()		
						else
							--TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.3),{ImageTransparency = 1}):Play()
							TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = 0}):Play()
						end
						if Settings.adsMesh2 then
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end
								end
							end
						else
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end
								end
							end
						end
					end
				else
					if AimPartMode == 1 then
						tweenFoV(Settings.ChangeFOV[1],120)
						if Settings.FocusOnSight then
							--TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.75),{ImageTransparency = 0}):Play()
							TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = Settings.Focus1Distance}):Play()
						else
							--TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.3),{ImageTransparency = 1}):Play()
							TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = 0}):Play()
						end
						if Settings.adsMesh1 then
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end
								end
							end
						else
							if Settings.adsMesh1 then
								for _,v in pairs(ArmaClone:GetDescendants()) do
									if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
										if v.Name == "REG" then
											TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
										end	
									end
								end
								for _,v in pairs(ArmaClone:GetDescendants()) do
									if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
										if v.Name == "ADS" then
											TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
										end
									end
								end
							end
						end
					elseif AimPartMode == 2 then
						tweenFoV(Settings.ChangeFOV[2],120)
						if Settings.FocusOnSight2 then
							--TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.75),{ImageTransparency = 0}):Play()
							TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = Settings.Focus2Distance}):Play()		
						else
							--TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.3),{ImageTransparency = 1}):Play()
							TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = 0}):Play()
						end
						if Settings.adsMesh2 then
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end
								end
							end
						else
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "REG" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
									end	
								end
							end
							for _,v in pairs(ArmaClone:GetDescendants()) do
								if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
									if v.Name == "ADS" then
										TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
									end
								end
							end
						end
					end
				end
			else
				tweenFoV(70,120)
				TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = 0}):Play()
				TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.3),{ImageTransparency = 1}):Play()
			end
		end
	elseif Aiming and Equipped  then
		stance = 0
		Evt.Stance:FireServer(stance,Settings,Anims,ArmaClient)
		game:GetService('UserInputService').MouseDeltaSensitivity = 1
		ArmaClone.Handle.AimUp:Play()	
		tweenFoV(70,120)
		Aiming = false
		if Settings.adsMesh1 or Settings.adsMesh2 then
			for _,v in pairs(ArmaClone:GetDescendants()) do
				if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
					if v.Name == "REG" then
						TS:Create(v, TweenInfo.new(0), {Transparency = 0}):Play()
					end	
				end
			end
			for _,v in pairs(ArmaClone:GetDescendants()) do
				if v:IsA('MeshPart') or v:IsA('Part') or v:IsA('UnionOperation') then
					if v.Name == "ADS" then
						TS:Create(v, TweenInfo.new(0), {Transparency = 1}):Play()
					end
				end
			end
		end
		TS:Create(StatusClone.Efeitos.Aim,TweenInfo.new(.3),{ImageTransparency = 1}):Play()
		TS:Create(game.Lighting.DepthOfField, TweenInfo.new(0.3), {FocusDistance = 0}):Play()
	end
end)
	
Human.Died:connect(function()
	ResetWorkspace()
	Human:UnequipTools()
	Evt.Rappel.CutEvent:FireServer()
	Unset()
end)


function onStateChanged(_,state)
	if state == Enum.HumanoidStateType.Swimming then
		Nadando = true
	if Equipped then
		Unset()
		Humanoid:UnequipTools()
	end
	else
		Nadando = false
	end

	if ServerConfig.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
				wait()
			end
			local damage = (curVel - (ServerConfig.MaxVelocity)) * ServerConfig.DamageMult
			if damage > 5 and peak > 20 then
					local hurtSound = PastaFX.FallDamage:Clone()
					hurtSound.Parent = Player.PlayerGui
					hurtSound.Volume = damage/Human.MaxHealth
					hurtSound:Play()
					Debris:AddItem(hurtSound,hurtSound.TimeLength)
				Evt.Damage:FireServer(Human,damage,0,0)
			end
		elseif state == Enum.HumanoidStateType.Landed or state == Enum.HumanoidStateType.Dead then
			falling = false
		end
	end
end

Evt.ServerBullet.OnClientEvent:Connect(function(SKP_arg1,SKP_arg3,SKP_arg4,SKP_arg5,SKP_arg6,SKP_arg7,SKP_arg8,SKP_arg9,SKP_arg10,SKP_arg11,SKP_arg12)
if SKP_arg1 ~= Jogador and SKP_arg1.Character then 
local SKP_01 = SKP_arg3
	local SKP_02 = Instance.new("Part")
	SKP_02.Parent = workspace.ACS_WorkSpace.Server
	SKP_02.Name = SKP_arg1.Name..'_Bullet'
	Debris:AddItem(SKP_02, 5)
	SKP_02.Shape = "Ball"
	SKP_02.Size = Vector3.new(1, 1, 1)
	SKP_02.CanCollide = false
	SKP_02.CFrame = SKP_01
	SKP_02.Transparency = 1

	local SKP_03 = SKP_02:GetMass()
	local SKP_04 = Instance.new('BodyForce', SKP_02)
	
	SKP_04.Force = Vector3.new(0,SKP_03 * (196.2) - SKP_arg5 * (196.2), 0)
	SKP_02.Velocity = SKP_arg7 * SKP_arg6

	local SKP_05 = Instance.new('Attachment', SKP_02)
	SKP_05.Position = Vector3.new(0.1, 0, 0)
	local SKP_06 = Instance.new('Attachment', SKP_02)
	SKP_06.Position = Vector3.new(-0.1, 0, 0)

	
	if SKP_arg4 then
		local SKP_07 = Instance.new('Trail', SKP_02)
		SKP_07.Attachment0 = SKP_05
		SKP_07.Attachment1 = SKP_06
		SKP_07.Transparency = NumberSequence.new({
				NumberSequenceKeypoint.new(0, 0, 0);
				NumberSequenceKeypoint.new(1, 1);
			}
		)
		SKP_07.WidthScale = NumberSequence.new({
				NumberSequenceKeypoint.new(0, 2, 0);
				NumberSequenceKeypoint.new(1, 0);
			}
		)
		SKP_07.Texture = "rbxassetid://232918622"
		SKP_07.TextureMode = Enum.TextureMode.Stretch
		SKP_07.LightEmission = 1
		SKP_07.Lifetime = 0.2
		SKP_07.FaceCamera = true
		SKP_07.Color = ColorSequence.new(SKP_arg8)
	end

	if SKP_arg10 then
	local SKP_08 = Instance.new("BillboardGui", SKP_02)
		SKP_08.Adornee = SKP_02
		local SKP_09 = math.random(375, 475)/10
		SKP_08.Size = UDim2.new(SKP_09, 0, SKP_09, 0)
		SKP_08.LightInfluence = 0
		local SKP_010 = Instance.new("ImageLabel", SKP_08)
		SKP_010.BackgroundTransparency = 1
		SKP_010.Size = UDim2.new(1, 0, 1, 0)
		SKP_010.Position = UDim2.new(0, 0, 0, 0)
		SKP_010.Image = "http://www.roblox.com/asset/?id=1047066405"
		SKP_010.ImageColor3 = SKP_arg11

		SKP_010.ImageTransparency = math.random(2, 5)/15
		
		if SKP_02:FindFirstChild("BillboardGui") ~= nil then
			SKP_02.BillboardGui.Enabled = true
		end
	end

	local SKP_011 = {SKP_arg1.Character,SKP_02,workspace.ACS_WorkSpace}
	while true do
		RS.Heartbeat:wait()
		local SKP_012 = Ray.new(SKP_02.Position, SKP_02.CFrame.LookVector*25)
		local SKP_013, SKP_014 = workspace:FindPartOnRayWithIgnoreList(SKP_012, SKP_011, false, true)
		if SKP_013 then
			game.Debris:AddItem(SKP_02,0)
			break
		end
	end
	game.Debris:AddItem(SKP_02,0)
	return SKP_02
end
end)

Human.StateChanged:connect(onStateChanged)

Evt.ACS_AI.AIBullet.OnClientEvent:Connect(function(SKP_arg1,SKP_arg3,SKP_arg4,SKP_arg5,SKP_arg6,SKP_arg7,SKP_arg8,SKP_arg9,SKP_arg10,SKP_arg11,SKP_arg12)
if SKP_arg1 ~= Jogador then 
local SKP_01 = SKP_arg3
	local SKP_02 = Instance.new("Part")
	SKP_02.Parent = workspace.ACS_WorkSpace.Server
	SKP_02.Name = "AI_Bullet"
	Debris:AddItem(SKP_02, 5)
	SKP_02.Shape = "Ball"
	SKP_02.Size = Vector3.new(1, 1, 1)
	SKP_02.CanCollide = false
	SKP_02.CFrame = SKP_01
	SKP_02.Transparency = 1

	local SKP_03 = SKP_02:GetMass()
	local SKP_04 = Instance.new('BodyForce', SKP_02)
	
	SKP_04.Force = Vector3.new(0,SKP_03 * (196.2) - SKP_arg5 * (196.2), 0)
	SKP_02.Velocity = SKP_arg7 * SKP_arg6

	local SKP_05 = Instance.new('Attachment', SKP_02)
	SKP_05.Position = Vector3.new(0.1, 0, 0)
	local SKP_06 = Instance.new('Attachment', SKP_02)
	SKP_06.Position = Vector3.new(-0.1, 0, 0)

	
	if SKP_arg4 then
		local SKP_07 = Instance.new('Trail', SKP_02)
		SKP_07.Attachment0 = SKP_05
		SKP_07.Attachment1 = SKP_06
		SKP_07.Transparency = NumberSequence.new({
				NumberSequenceKeypoint.new(0, 0, 0);
				NumberSequenceKeypoint.new(1, 1);
			}
		)
		SKP_07.WidthScale = NumberSequence.new({
				NumberSequenceKeypoint.new(0, 2, 0);
				NumberSequenceKeypoint.new(1, 0);
			}
		)
		SKP_07.Texture = "rbxassetid://232918622"
		SKP_07.TextureMode = Enum.TextureMode.Stretch
		SKP_07.LightEmission = 1
		SKP_07.Lifetime = 0.2
		SKP_07.FaceCamera = true
		SKP_07.Color = ColorSequence.new(SKP_arg8)
	end

	if SKP_arg10 then
	local SKP_08 = Instance.new("BillboardGui", SKP_02)
		SKP_08.Adornee = SKP_02
		local SKP_09 = math.random(375, 475)/10
		SKP_08.Size = UDim2.new(SKP_09, 0, SKP_09, 0)
		SKP_08.LightInfluence = 0
		local SKP_010 = Instance.new("ImageLabel", SKP_08)
		SKP_010.BackgroundTransparency = 1
		SKP_010.Size = UDim2.new(1, 0, 1, 0)
		SKP_010.Position = UDim2.new(0, 0, 0, 0)
		SKP_010.Image = "http://www.roblox.com/asset/?id=1047066405"
		SKP_010.ImageColor3 = SKP_arg11

		SKP_010.ImageTransparency = math.random(2, 5)/15
		
		if SKP_02:FindFirstChild("BillboardGui") ~= nil then
			SKP_02.BillboardGui.Enabled = true
		end
	end

	local SKP_011 = {SKP_02,workspace.ACS_WorkSpace}
	while true do
		RS.Heartbeat:wait()
		local SKP_012 = Ray.new(SKP_02.Position, SKP_02.CFrame.LookVector*25)
		local SKP_013, SKP_014 = workspace:FindPartOnRayWithIgnoreList(SKP_012, SKP_011, false, true)
		if SKP_013 then
			game.Debris:AddItem(SKP_02,0)
			break
		end
	end
	game.Debris:AddItem(SKP_02,0)
	return SKP_02
end
end)

Evt.ACS_AI.AIShoot.OnClientEvent:Connect(function(Gun)

	for _, v in pairs(Gun.Muzzle:GetChildren()) do
				if v.Name:sub(1, 7) == "FlashFX" or v.Name:sub(1, 7) == "Smoke" then
					v.Enabled = true
					end
				end

		delay(1 / 30, function()

			for _, v in pairs(Gun.Muzzle:GetChildren()) do
				if v.Name:sub(1, 7) == "FlashFX" or v.Name:sub(1, 7) == "Smoke" then
					v.Enabled = false
				end
			end
		end)		
	
end)
