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

My hotel game laggs a lot, is there any script I can make to help with the lagg?

Hi I built a Hotel and it really laggs like a LOT it's really slow could anyone help me with a script for it? I put a couple anti laggs from free models but it still laggs a lot :/

3 comments

0

Don't use free models. "Anti-Lag" models only make it worse because it does the opposite of "Anti-Lag".

0

And can add unwanted backdoor scripts.

0

Okay thanks I will remove them.

3 answers

✓ Accepted answer

This may be caused to do viruses in the game. If you search up "Vaccine" in the search on your explorer and scripts come up named Vaccine, delete them. These scripts are viruses and will cause lag. Next thing you could do it search "script" in the explorer and if any scripts come up that you know you didn't make and have random named, delete them.

Do not use anti-lag free models, these make the game worse.

2 comments

0

Ecoszns is right. Also, to help find viruses/backdoor scripts use this Roblox plugin: https://web.roblox.com/library/2670956620/Hidden-Infection-Script-Detector

0

Okay I will remove them, thank you so much for the help!

Reduce the graphics quality or use this script:

mx = game.Debris
mx2 = game.Debris.MaxItems


if (mx.MaxItems > 9999999999) then
	mx.MaxItems = mx2* .9999999999
end

4 comments

0

Might be deprecated though.

0

^ You’re right about it being deprecated, but it’s also restricted and will error if used. I recommend you don’t use it: https://developer.roblox.com/en-us/api-reference/property/Debris/MaxItems

0

Ok. Then just reduce the graphics quality.

0

Okay.

There are various ways your game can lag, like excessive parts, script loops, viruses, etc.

If you are making a game that uses a lot of parts, you could try uniting them to make fewer parts, or setting workspace.StreamingEnabled to true. StreamingEnabled makes your game load parts only within a certain distance for the player. You have to take into account some objects that are not loaded wont be available for the player when using localscripts, and you will have to adapt them to this case.

if you have too many script loops, you can try increasing the wait time of such loop or changing some of them to events. For example, if you are checking if a player have a "Sword" tool inside their backpack, you could change the "while true do" to "player.Backpack.ChildAdded:Connect().

In case you are with a virus, which are commonly named like "Vaccine" or "yOuGotPwNedxsdsd", they can decrease performance a lot with the many loops they create.

To prevent this from happening, always insert freemodels while your not running the game and check if it has a script inside, even if it was just a mesh you wanted to use.

To remove them, you can use the following code. NOTICE that if you have game objects with similar name and classname as the virus, it WILL get destroyed, so create a backup for them before you run it. Add virus names and classnames you are dealing with on line 3 and 4.

--This script will search all items with a specific name and specific classname you set
local searchitems = {game.Workspace,game.Lighting} --Add directories to search
local targetname = {"Vaccine","Fire","Spread"} --Add scriptvirus names you are struggling with
local targetclassname = {"Script","Fire"} --Sometimes viruses replicate along with a different game object, like fire. Add them here.
local collected = {}
for i=1,#searchitems do
	local descendants = searchitems[i]:GetDescendants()
	for a=1,#descendants do
		local matchname = false
		local matchclassname = false
		for z=1,#targetname do
			if descendants[a].Name == targetname[z] then
				matchname = true
			end
		end
		for z=1,#targetclassname do
			if descendants[a].ClassName == targetclassname[z] then
				matchclassname = true
			end
		end
		if matchname == true and matchclassname == true then
			if descendants[a]:IsA("BaseScript") then--sometimes scripts have a way to reinsert themselves, so we need to disable them before that
				descendants[a].Disabled = true
			end
			table.insert(collected,1,descendants[a])
		end
	end
end
for i=1,#collected do
	collected[i]:Destroy()
end

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