2 questions So i'm working on a machine gun but i want to to shoot out multiple bullets at once and or have a spraying effect that shoots out 1 bullet but the CFrame positions are random. Heres my script
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local Ammo = 1 --CUSTOMIZE-- Mouse.Button1Down:connect(function() if Ammo > 0 then local x = Instance.new("Part", workspace) Ammo = Ammo-1 x.Shape = "Block" x.CanCollide = false x.Size = Vector3.new(0.5, 0.5, 1.5) x.BrickColor = BrickColor.new("Bright yellow") x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,0,-3) --DAMAGE-- x.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then hit.Parent.Humanoid:TakeDamage(12.5) x:remove() end end) --VELOCITY-- local v = Instance.new("BodyVelocity", x) v.Velocity = Player.Character.Torso.CFrame.lookVector * 150 v.maxForce = Vector3.new(math.huge, math.huge, math.huge) x.Parent = workspace wait(1.25) x:remove() end end) --AMMO-- while true do if Ammo == 0 then wait(0.1) Ammo = 1 end wait(0.1) end
For my first question about shooting multiple parts at once, i duplicated the script and it works but im wondering if theres a less messy way of doing it without having so many scripts
And for my 2nd question about the spraying, i tried using or
but that doesn't work