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

Studio keeps crashing on error alert system I made?

I have lived with this problem for a while, but I think it's finally time to fix it. Studio keeps crashing on this script:

local ScriptContext = game:GetService("ScriptContext")
local PluginMouse = plugin:GetMouse()
Alert = script.Alert -- Bug fix attempt
FirstTime = true -- Bug fix attempt
ScriptContext.Error:Connect(function(message, stackTrace, scriptinstance) -- Runs when an error happens
	if FirstTime == false then -- Bug fix attempt
	local alert = Alert:Clone()
	local line1 = "  "..tostring(scriptinstance.Name)..", "..tostring(string.gsub(stackTrace, scriptinstance:GetFullName()..", ", "")) -- Script instance and line number (where error occured)
	local replacement = scriptinstance:GetFullName()..":"..string.gsub(stackTrace, scriptinstance:GetFullName()..", line ", "") -- The second argument in string.gsub: the script instance found in an error message
	local replacement2 = string.gsub(replacement, "\.", "\.")
	local preline2 = "  '"..string.gsub(message, replacement2, "").."'"
	local line2 = string.gsub(preline2, "' ", "'") -- The string.gsub that removes script instance from error message
	alert.Location.Text = line1 -- Script instance and line number
	alert.ErrorMessage.Text = line2 -- Error message by itself
	local linenumber = tonumber(tostring(string.gsub(string.gsub(stackTrace, scriptinstance:GetFullName()..", line ", ""), " ", ""))) -- Line number by itself
	alert.Location.LineNumber.Value = linenumber -- For plugin:OpenScript on script that is getting cloned (easy access to where error occured)
	alert.Location.ScriptInstance.Value = scriptinstance -- Also for plugin:OpenScript
	alert.Parent = script.Parent -- From here is the part where the error appears and sound is played
	local ErrorSound = Instance.new("Sound")
	ErrorSound.SoundId = "rbxassetid://5188022160"
	ErrorSound.PlayOnRemove = true
	ErrorSound.Parent = game.Workspace
	ErrorSound:Destroy()
	local script1 = require(alert.MovementScript)
	local script2 = require(alert.Location.ShortcutScript)
	local script3 = require(alert.DestroyScript)
	alert:Destroy() -- Error has disappeared and will now be deleted
	end
end)
FirstTime = false -- Bug fix attempt

This is part of an error alert system for my plugin. This script is in control of cloning and running all the scripts that are inside the clone. The system works fine.

Anyways, the error is: 14:45:34.627 - CoreGui.DevHelper 2.Script:8: attempt to index nil with 'Name'

And of course: 14:45:34.626 - Maximum event re-entrancy depth exceeded for ScriptContext.Error

What is happening and how do I fix it?

1 comment

0

Your script is formatted terribly bad

1 answer

most of the time this means that the script is running too fast try adding a Wait() or debounce at the start of every function , this error is similar to Script timeout: exhausted allowed execution time OR that you're erroring in a callback function that's called for every error. a user by the name of "Link150" explains this in detail heres the link for it

https://scriptinghelpers.org/questions/32215/maximum-event-re-entrancy-depth-exceeded-for-intvaluechanged

2 comments

0

I know that the script is running too fast, I'm asking why. Also tried it out, didn't work.

0

Also, I've already seen it a million times

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