Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
hudzell 238 Moderation Voter
10 years ago

(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
0
Why is "Enabled" a BoolValue instead of just a variable, is it used in another one of the scripts?\ duckwit 1404 — 10y
0
Oh, no it is not, let me change that hudzell 238 — 10y
0
Just to check (I haven't looked incredible,y pensively at your script) is this the script that has the re-entrancy error? duckwit 1404 — 10y
0
Yes it is hudzell 238 — 10y
0
Thanks guys, it worked! But I'm still having a problem. Just now working on the question hudzell 238 — 10y

1 answer

Log in to vote
1
Answered by
Bebee2 195
10 years ago

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.

0
Definitely need to add the FindFirstChild - but doesn't he already have debounce in there? The variable he uses is called Enabled. duckwit 1404 — 10y
Ad

Answer this question