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

Maximum re-entrancy depth exceeded for ScriptContext.Error ?

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)

3 comments

0

Use Code Block.

0

do you have any .Changed code?

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"

2 answers

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!

1 comment

0

Ok ill check and edit the post

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.

1 comment

0

Didnt Fix anything else

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