Help! A skill in my game is crashing people!

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.

1 Like

Roblox Explosion Particle in tons can crash it, so, make explosion particle only once, it happens when you explode too many explosions that lagging your computer at nearby camera.

1 Like

There are no explosion objects in the script.

Are just individual players crashing or are servers lagging out and crashing? If its individual players do they just freeze or slowly start to lose FPS? When do they crash? As soon as they use it or only when doing damage to someone?

Could it be every time you are trying to apply damage to a target you are re-indexing all the descendants of workspace? Keep in mind everything inside of that loop is going to be ran 20x, if every bit of the effect hits a player you are Getting all descendants of workspace 20x assuming you didn’t hit more than one person. From the looks of it there just appears to be a lot of things being ran in such a short amount of time. I would also look into proper clean-ups in the code such as disconnecting the touched event after it hits someone for example and look into a better way of handling damage without having to re-index descendants each time. Hope this helps (:

I figured out why it was happening, thanks anyways.

Mind sharing the conclusion you reached? It would help others out in the instance that they reach the same problem as you.

The solution isn’t really very helpful, as it turned out that the “blind” effect the skill applied was crashing players.

You mean to say that something unrelated was causing the crashes? The unrelated thing being another system that was working in tandem with this skill.

Yeah, basically I’d broken another system a few weeks earlier accidentally and it ended up spamming errors into the console every time it was called which caused clients affected by the move to crash.

2 Likes