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

Maximum re-entrancy depth exceeded for ScriptContext.Error ?

Asked by 4 years ago
Edited 4 years ago

I am making a simulator but when I click with the sword it freezes and crashes the game.

The script:

script.AddSlash.OnServerEvent:Connect(function(player)
    player.leaderstats.Slashes.Value = player.leaderstats.Slashes.Value +1
    end)
script.AddXP.OnServerEvent:Connect(function(player)
    player.leaderstats.EXP.Value = player.leaderstats.EXP.Value +1


end)

Other Script:

local cooldown = false

script.Parent.Activated:Connect(function()
    if cooldown == false then
        cooldown = true
    game.Workspace.MainEvent2.AddSlash:FireServer()
    wait(0.5)
    cooldown = false
    end
end)
0
Use Code Block. Dovydas1118 1495 — 4y
0
do you have any .Changed code? zadobyte 692 — 4y
0
You have a while loop without a wait. To figure out where it is, press Ctrl+Shift+F (or Cmd+Shift+F) then type "while" User#30567 0 — 4y

2 answers

Log in to vote
2
Answered by
Optikk 499 Donator Moderation Voter
4 years ago

The code you gave us doesn't seem relevant to your error. That message looks to be due to an error occurring in the ScriptContext.Error event (and I don't think you would get that error under any other circumstances.)

To fix this issue, you're going to have to track down wherever you used ScriptContext.Error and make sure that you don't have any erroneous code.

Let me know if this helps any!

0
Ok ill check and edit the post jhjryoutube 29 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Right, Don't use Enabled as it is unreliable. Instead, keep going with the cooldown.

local cooldown = false

script.Parent.Activated:Connect(function()
    if cooldown == false then
        cooldown = true
        game.Workspace.MainEvent2.AddSlash:FireServer()
        wait(0.5)
        cooldown = false
    end
end)

I see nothing wrong this code.

0
Didnt Fix anything else jhjryoutube 29 — 4y

Answer this question