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 :/
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.
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
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