ModuleScript Script analysis crashing Studio (memory leak + potential computer crash)

First of all: I’m making this report here because Regular rank is locked and I can’t report it in the right category.

I was making a simple shooting function for a character in my fighting game, before that it checks for how much ammunition the revolver has (yeah, not cleaned up and messy, don’t mind that)

In this function, I noticed something which led to my computer freezing completely (100% repro).
I deleted the buggy lines, and tried to rewrite something as simple as:
image
Which should display this UI with the possible functionalities containing “Find”

Right here, a deadly process begins, in which Studio creates a memory leak I can’t track down, in a matter of seconds my computer will overwork to the point where it’s completely frozen.

Before adding anything else, I’ll paste the code (which doesn’t cause any issues in play testing nor Roblox Player, making me think it’s script analysis).

I’ll copy paste the ModuleScript’s code below:


local function shoot(player)
local chr = player.Character
local ammo = chr.Ammo
local gun = chr.Gun
local shootpart = gun.Aimer
if ammo.Value == 0 then 
	speedmodule.speed(chr, 0, 0)
	local reload = chr.Humanoid.Animator:LoadAnimation(game.ServerScriptService.CombatRemotes.Mista.Reload)
	reload:GetMarkerReachedSignal("SFX1"):Connect(function()
		shootpart.ReloadSFX1:Play()
	end)
	local parts = gun.Ammo:GetChildren()
	reload:GetMarkerReachedSignal("drop"):Connect(function()
		for i,part in pairs(parts) do
			if string.find(part.Name, "Case") then
				part.Transparency = 1
			end
		end
	end)
	reload:GetMarkerReachedSignal("SFX2"):Connect(function()
		shootpart.ReloadSFX2:Play()
		for i,part in pairs(parts) do
			if string.find(part.Name, "Bullet") then
				part.Transparency = 0
			end
		end
	end)
	animationmodule.animation(chr, reload, 1.1)
	ammo.Value = 6
	reload.Stopped:Wait()
	speedmodule.speed(chr, "default", "default")
return end

ammo.Value = ammo.Value-1

local bullet = game.ServerStorage.Bullet:Clone()
shootpart.ShootSFX:Play()
end

module.move2 = function(player)
	local chr = player.Character
	if chr.Barraging.Value == true then
		chr.Barraging.Value = false
		return
	end
	if chr.Attacking.Value == true then return end
	local human = chr.Humanoid
	local stand = chr:WaitForChild("Stand")
	chr.Attacking.Value = true
	chr.Barraging.Value = true
	--if chr.StandEnabled.Value == true then
		repeat shoot(player) wait(0.6) until chr.Barraging.Value == false
		chr.Attacking.Value = false
	--end
--end
end

return module

Now type:
gun.Ammo:FindFirstChild("Bullet"..ammo.Value).Transparency = 1 gun.Ammo:FindFirstChild("Case"..ammo.Value).Transparency = 0
right above
ammo.Value = ammo.Value-1

Let me know if you can reproduce, limit your Studio’s CPU usage just to be safe.

1 Like

Updated the repro steps as they were incorrect.

In a simple baseplate it seems to be just delayed and not a crash at all times, nor PC related, maybe it happens in bigger places (where I encountered it).

image

The computer problem is no longer happening! But Studio crashes.

I’ve had a similar thing happen to me quite a few times! My studio literally crashes.

1 Like