Please help fix my scripts

so, i put a ton of scripts in my game, but it somehow crashed it.
so can someone please help me by joining my game to fix all of the scripts?

just jot down your username so i can add you to team create

Don’t do this!!!

Anyone you add would now be able to get into your game and steal it/break it/delete it!!!

Did you put free scripts from the toolbox in your game? That’s dangerous as well. There are tons of harmful corrupted scripts in the toolbox.

Go into your game and disable all the scripts you added.
Enable them one at a time to see which one is crashing your game. When you find it either fix it or delete it.

Infected plugins can also wreak havoc on your game. Be very careful with those too, and only use plugins from trusted sources.

8 Likes

hmm ehhh try this, but dont do this if you have made scripts (you have to do another way)

local sFound = false

while true do
    task.wait(1)

    for _, s in pairs(game:GetDescendants()) do
        if s:IsA("Script") or s:IsA("LocalScript") or s:IsA("ModuleScript") and s.Name ~= script.Name then
            s.Enabled = false -- (rechanged because Dev_Peashie suggested, :Destroy() was too extreme but just change it to :Destroy() if the script is re-enabling itself :D) 
            sFound = true -- update the boolean variable
        end
    end

    if not sFound then -- check if no "s" objects were found
        print("No more 's' objects in the game")
        break -- exit the loop
    end

    sFound = false -- reset the variable cuz why not? (remove this line if you dont want this to repeat i guess)
end

or maybe you might try

while true do -- loop
      task.wait(1) -- delay so it wont lag
      for _, s in pairs(game:GetDescendants()) do -- change "game" on where your script is located or leave it if its everywhere (Dev_Peashie suggested)
           if s:IsA("Script") or s:IsA("LocalScript") or s:IsA("ModuleScript") and s.Name ~= script.Name then -- check if it is any type of script and if it not the name of your scirpt to avoid deleting this (also change this scripts name not the same as the others)
                 s.Enabled = false -- disable the script (Dev_Peashie said :Destroy() was too extreme)
            end
      end
end
1 Like

Thats a good idea, but Destroy() is a little extreme, would be better to only set Enable = false on each script found for later inspection. And locationOfScript variable, could be game.
for _, s in pairs(game:GetDescendants()) do

No need to set task.wait(1) to one second, if you iterate whole game. with only task.wait() or even not using a wait should work I think

ah makes sense, ill re-edit i also do not know whats best between task.wait() and wait() lol.
also if the script can re-enable the script itself they canu se :Destroy() :grin:

1 Like

Nah, I just mean, that could possibly be thousands of instances in the game. If you run a loop waiting 1 second per instance found, then 20k instances in game will make you wait 20k seconds for the loop to finish.
task.wait() without any number its just the minimal possible wait time per iteration to not overload the tasks. Which is the safer way with the minimal wait time.
By no using a wait, its like forcing the loop, causing lag.
Not really important, cause this is not for the gameplay, its just for disable scripts while in studio using the command bar.

task.wait() is a new and improved version of wait, so you should always use that. Also, the script you provided will currently wipe all scripts every second forever. Instead, I’d just do this:

-- Destroy all scripts:
local s = game:FindFirstChildWhichIsA("BaseScript", true)
while s do
	s:Destroy()
	s = game:FindFirstChildWhichIsA("BaseScript", true)
end

or

-- Disable all scripts:
for _, s: Instance in pairs(game:GetDescendants()) do
	if not s:IsA("BaseScript") then continue end -- Only care for LocalScripts and Scripts
	
	s.Enabled = false
end

NOTE: Make sure to run chosen version from command line. Otherwise the changes will only last during the playtest.

1 Like

Would be cool to print some information for later too

local scan = game:GetDescendants()
local scriptsTable = {}
local scriptsCount = 0
for _, s in ipairs(scan) do
	if s:IsA("BaseScript") then
		scriptsCount += 1
		scriptsTable[s.Name] = scriptsTable[s.Name] or {}
		table.insert(scriptsTable[s.Name], s)
		s.Enabled = false -- disable ot destroy
	end
end
warn("Scripts in game:", scriptsCount)
warn(scriptsTable)

thanks guys i shall try it out later

2 Likes

Never put free scripts in your game. They may contain viruses. If you want to find them and delete, open the explorer in Roblox Studio and in the filter type Script. It will show you all the scripts. If you are good at scripting, you may know what some of them do. Also studio shows when you add a modal, that it contains scripts. Check all of them.

oh they were youtubers’ scripts

I’ve seen people say that if your game is too resource intensive (such as it requires too much memory) then it will crash your system. I don’t know if this is true but it if it is, then try to optimize the scripts, make them less resource intensive, that should hopefully fix the issues. And also delete any scripts which are mostly unneccesary.

That’s probably the problem. Most of those scripts are probably outdated, and dont work anymore.


I would recommend learning to script instead of just using youtubers code, this usually ends up happening,


~Froyo~

If your Studio crashed it may also be because an undelayed loop is present.

SHHHHHH… why you gotta make things so hard for ppl??

How am i making it hard for people?

nvm. pls just ignore that thanks! Have a nice day!

1 Like

thank you guys, i managed to fix my scripts

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.