I'm trying to make a gun fire three different bullets in a fashion similar to a shotgun, but I can't figure it out. What should I do to this script to get it to work?
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)
Simple, Just make about 6 parts, set their position to math.random(10,0,-5)
You can also do math.random(player.mouse.p)
I'll message you my gun script,It's to long to put in the Answers but here you go.