(I reposted this because nobody saw the previous post) I was trying to make a gun that shoots random bullets, but everytime I try to make it shoot random bullets, it either shoots only one everytime, or it just doesn’t shoot at all. I’m using a script someone else made and modifying it to turn it into what I want it to be
script
script.Parent.OnServerEvent:Connect(function(plr)
local folder = game.ReplicatedStorage.MK2Ammo
local Red = folder.Red
local Orange = folder.Orange
local Yellow = folder.Yellow
local Green = folder.Green
local Blue = folder.Blue
local Purple = folder.Purple
local Pink = folder.Pink
local selecteditem = {Red, Yellow, Orange, Green, Blue, Purple, Pink}
local Slash = game.ReplicatedStorage.MK2Ammo.selecteditem.OuterBullet:Clone()--change the attack name
local Slash2 = game.ReplicatedStorage.MK2Ammo.selecteditem.InnerBullet:Clone()--change the attack name
Slash.Parent = workspace
Slash.CanCollide = false
Slash.Anchored = false
Slash.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(2,0,2) * CFrame.fromEulerAnglesXYZ(5,0,5)
Slash2.Parent = workspace
Slash2.CanCollide = false
Slash2.Anchored = false
Slash2.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(2,0,2) * CFrame.fromEulerAnglesXYZ(5,0,5)
local Weld = Instance.new("WeldConstraint")
Weld.Parent = Slash
Weld.Part0 = Slash
Weld.Part1 = Slash2
Slash.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name then
local Explosion = game.ReplicatedStorage.LightingPew.Explosion:Clone()--change folder name
Explosion.Parent = workspace
Explosion.CFrame = Slash.CFrame
Explosion.CanCollide = false
Explosion.Anchored = true
Slash:Destroy()
hit.Parent.Humanoid:TakeDamage(15) --Change damage
for i = 1,18 do
wait(.05)
Explosion.Size = Explosion.Size + Vector3.new(2,2,2)
Explosion.Transparency = Explosion.Transparency + 1
end
Explosion:Destroy()
end
end)
local BV = Instance.new("BodyVelocity",Slash)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 100
end)
but everytime I tried to use math.random, it came with an error saying “selected item isn’t a child of MKAmmo” or something. I’m most likely using it wrong
On the lines beginning local Slash = and local Slash2 =, just use randombullet.OuterBullet:Clone() instead of game.ReplicatedStorage.randombullet. I assume that’s the cause anyway