--	missile.Velocity = v * iv     MOVED DOWN

	missile.BrickColor=cc
	missile.Shape = 0
	missile.BottomSurface = 0
	missile.TopSurface = 0
	missile.Name = "Paintball"
	missile.Elasticity = 0
	missile.Reflectance = 0
	missile.Friction = .9
	missile.CanCollide=false

	local force = Instance.new("BodyForce")
	force.force = Vector3.new(0,90,0)
	force.Parent = missile
	
	Tool.BrickCleanup:clone().Parent = missile

	local new_script = pbs:clone()
	new_script.Disabled = false
	new_script.Parent = missile

	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = vPlayer
	creator_tag.Name = "creator"
	creator_tag.Parent = missile
	
	if mode==3 then
		local m1=missile:clone()
		m1.Position=spawnPos + v*2.5 + Vector3.new(0,-0.5,0) + vCharacter.PrimaryPart.CFrame.lookVector*2
		m1.Velocity = Vector3.new(v.x*math.random(85, 115)/100, v.y*math.random(85, 115)/100, v.z*math.random(85, 115)/100)*iv --, (5*v+Vector3.new(math.random(-1,-1),math.random(-1,-1),math.random(-1,-1)))/5 * iv
		--print("x=" .. m1.Velocity.x .. ",     y=" .. m1.Velocity.y .. ",     z=" .. m1.Velocity.x .. ".")
		m1.Parent=workspace

		local m2=missile:clone()
		m2.Position=spawnPos + v*2 + Vector3.new(0,.5,0) + vCharacter.PrimaryPart.CFrame.lookVector*3
		m2.Velocity = Vector3.new(v.x*math.random(85, 115)/100, v.y*math.random(85, 115)/100, v.z*math.random(85, 115)/100)*iv
		m2.Parent=workspace

		local m3=missile:clone()
		m3.Position=spawnPos + v*3.5 + vCharacter.PrimaryPart.CFrame.lookVector*1
		m3.Velocity = Vector3.new(v.x*math.random(85, 115)/100, v.y*math.random(85, 115)/100, v.z*math.random(85, 115)/100)*iv
		m3.Parent=workspace
	else
		missile.Position = spawnPos + v*2.5 + vCharacter.PrimaryPart.CFrame.lookVector*2
		missile.Velocity = v * iv
		missile.Parent = workspace
	end
end



function dropwep()
	connection:disconnect()
	wait(1)
	Tool.Parent=game.Workspace
	wait(14)
	--not been picked up then remove it. 
	if Tool.Parent==game.Workspace then Tool.Parent=nil end
end





Tool.Enabled = true
function onActivated()
	if not Tool.Enabled then
		return
	end
	connection=script.Parent.Parent.Humanoid.Died:connect(dropwep)
	Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return 
	end

	local targetPos = humanoid.TargetPoint
	
	
	if gren and nadeloaded then
		gren=false
		Tool.Enabled = true
		firenade(targetPos)
	else
		local lookAt = (targetPos - character.Head.Position).unit
		fire(lookAt)
		wait(reloadtime)
		
		Tool.Enabled = true
	end
end


script.Parent.Activated:connect(onActivated)

