Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"maximum event re-entrancy depth exceeded" Error, anyone know how to fix? [UPDATE]

(Scroll down for old code)

Oh, by the way, the error occurs when I equip the tool

Just edited it a bit, still says the same thing, but here's the code again. (Layout)

local tool = script.Parent
local handle = tool.Handle
local light = handle.PointLight
local player = game.Players.LocalPlayer
local Enabled = true

function activated()
	if Enabled == true then
		Enabled = false
		wait()
		local col = script.collide:Clone()
		col.Parent = tool
		col.Position = handle.Position
		col.Anchored = false
		wait()
		light.Brightness = 100
		light.Range = 48
		wait()
		col.Touched:connect(function(hit)
			if hit.Parent.Humanoid and hit.Parent.Name ~= player.Name then
				hit.Parent.Humanoid:TakeDamage(10)
			end
		end)
		wait(.1)
		light.Brightness = 1
		light.Range = 16
		tool:FindFirstChild("collide"):Destroy()
		wait(.3)
		Enabled = true
	end
end

script.Parent.Activated:connect(activated)

Here is the code, but before you look at it, look at this.

local tool = script.Parent
local handle = tool.Handle
local light = handle.PointLight
local player = game.Players.LocalPlayer

function activated()
	if script.Enabled == true then
		script.Enabled = false
		local col = script.collide:Clone()
		col.Parent = tool
		col.Position = handle.Position
		col.Anchored = false
		light.Brightness = 100
		light.Range = 48
		col.Touched:connect(function(hit)
			if hit.Parent.Humanoid and hit.Parent.Name ~= player.Name then
				hit.Parent.Humanoid:TakeDamage(10)
			end
		end)
		wait(.1)
		light.Brightness = 1
		light.Range = 16
		tool:FindFirstChild("collide"):Destroy()
		wait(.3)
		script.Enabled = true
	end
end

script.Parent.Activated:connect(activated)

Oh, and here's the code for the script I made to attempt to fix it. (The "Script" inside the Light Orb)

while true do --Fix
	wait(1)
	if not script.Parent.LocalScript.collide then
		local c = game.Lighting.Storage.collide:Clone()
		c.Parent = script
	end
end

5 comments

0

Why is "Enabled" a BoolValue instead of just a variable, is it used in another one of the scripts?\

0

Oh, no it is not, let me change that

0

Just to check (I haven't looked incredible,y pensively at your script) is this the script that has the re-entrancy error?

0

Yes it is

0

Thanks guys, it worked! But I'm still having a problem. Just now working on the question

1 answer

✓ Accepted answer

Maximum retry depth error usually comes from recursing the same function over and over.

I'll tell you where this infinite loop is.

EDIT: Worth a shot but @ line 16, use if hit.Parent:FindFirstachild'Humanoid'

And also try adding debounce to that event.

1 comment

0

Definitely need to add the FindFirstChild - but doesn't he already have debounce in there? The variable he uses is called Enabled.

This discussion is preserved as it was. New answers, comments, and votes are closed.