General
A “projectile barrage” skill in my game is crashing players despite it never doing that before, and the skill has been out for ages. I haven’t touched the skill (at least I think) in weeks before this.
Basically what the move does is that it creates around 20 projectiles (the issue is not the projectile count, the game has easily handled them before) which are shot from the torso. They all will explode on impact, creating an AOE. (The effects tween on the client.)
Code
Main sections:
local hand = rhand
for attack = 1,20,1 do
wait(0.0825)
local firing = sounds:WaitForChild("Fire"):Clone()
firing.Parent = root
firing.Playing = true
game:GetService("Debris"):AddItem(firing,firing.TimeLength)
local proj = game.ServerStorage.LightProjectile:Clone()
proj.Parent = workspace:WaitForChild("Effects")
proj.CFrame = hand.CFrame
if hand == rhand then
hand = lhand
else
hand = rhand
end
proj.Anchored = false
game:GetService("Debris"):AddItem(proj,10)
local already = Instance.new("BoolValue")
already.Value = false
already.Name = "AlreadyHit"
already.Parent = proj
local bv = Instance.new("BodyVelocity")
bv.Parent = proj
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.P = 10000000
bv.Velocity = root.CFrame.lookVector * 180
proj.Touched:connect(function(hit)
if already.Value == false then
local checkifbari = hit:FindFirstChild("DeflectCooldown")
if hit.Transparency ~= 1 and checkifbari == nil and hit:IsDescendantOf(char) == false and hit.Name ~= "YasakaniFX1" and hit.Name ~= "YasakaniFX2" and hit.Name ~= "YasakaniFX3" and hit.Name ~= "LightProjectile" and hit.Name ~= "Water" then
already.Value = true
proj.Anchored = true
proj.Transparency = 1
local get = proj:GetDescendants()
for i,get in pairs(get) do
if get.ClassName == "ParticleEmitter" then
get:Destroy()
end
end
local orb = game.ServerStorage.LightOrb:Clone()
orb.Parent = workspace:WaitForChild("Effects")
orb.CFrame = CFrame.new(proj.Position)
orb.Size = Vector3.new(2,2,2)
orb.Transparency = 0
orb.BrickColor = BrickColor.new("Ghost grey")
orb.Name = "YasakaniFX1"
game:GetService("Debris"):AddItem(orb,4)
local orb2 = game.ServerStorage.LightOrb:Clone()
orb2.Parent = workspace:WaitForChild("Effects")
orb2.CFrame = CFrame.new(proj.Position)
orb2.Size = Vector3.new(3,3,3)
orb2.Transparency = 0
orb2.Name = "YasakaniFX2"
game:GetService("Debris"):AddItem(orb2,0.8)
local firing = sounds:WaitForChild("Explode"):Clone()
firing.Parent = orb
firing.Playing = true
game:GetService("Debris"):AddItem(firing,firing.TimeLength)
damage(player,proj,35,level.Value / damagenum)
end
end
end)
end
Damage function:
local function damage(player,part,range,damage)
local getw = game.Workspace:GetDescendants()
for i,getw in pairs(getw) do
if getw.ClassName == "Humanoid" then
if getw.Parent.Name ~= player.Name then
local ptorso = getw.Parent:FindFirstChild("HumanoidRootPart")
if ptorso then
if (part.Position - ptorso.Position).magnitude <= range then
getw:TakeDamage(damage)
local find = getw:FindFirstChild("LastHitBy")
if find then
find.Value = player.Name
end
local blind = getw:FindFirstChild("LightBlinds")
if blind then
blind.Value = blind.Value + 1
end
end
end
end
end
end
end
Mind the shoddy code, this game is old and isn’t coded well. It usually works, though.
Any help would be appreciated as I have zero idea what’s causing this.