I'm trying to make this gun fire 3 different bullets in a slightly random direction, and I have no idea how. Here is the fire script:
local Tool = script.Parent
enabled = true
function fire(v)
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local Torso = vCharacter.Torso
local spawnPos = Torso.Position
spawnPos = spawnPos + (v * 3)
for i = 1,3 do
local missile = Instance.new("Part")
missile.Position = spawnPos
missile.Size = Vector3.new(0.6,0.6,0.6)
missile.Velocity = v * 300
missile.BrickColor = BrickColor.new("Dark stone grey")
missile.Shape = "Ball"
missile.BottomSurface = "Smooth"
missile.TopSurface = "Smooth"
missile.Name = "Bullet"
missile.Elasticity = 0
missile.Reflectance = 0
missile.Friction = .9
missile.Parent = game.Workspace
local DmgScript = script.Parent.BulletDamage:Clone()
DmgScript.Disabled = false
DmgScript.Parent = missile
local Delay = script.Parent.DelayedRemover:Clone()
Delay.Disabled = false
Delay.Parent = missile
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,100,0)
force.Parent = missile
end
end
function onActivate()
if enabled == true then
enabled = false
local character = Tool.Parent
local humanoid = character.Humanoid
local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit
script.Parent.Handle.Sound:Play()
fire(lookAt)
wait(0.6)
enabled = true
end
end
script.Parent.Activated:connect(onActivate) |