Advertisement
Josiahiscool73

Anti lag script

Jul 11th, 2023
848
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. -- this script was made by chatgpt and me with a few tweaks that are good
  2.  
  3. local function optimizeGame()
  4. game:GetService("Workspace").StreamingEnabled = true -- Enable streaming to load parts dynamically
  5.  
  6. for _, part in ipairs(game:GetService("Workspace"):GetDescendants()) do
  7. if part:IsA("BasePart") then
  8. part.Anchored = true -- Set all parts to be anchored for performance optimization
  9. end
  10. end
  11.  
  12. game:GetService("RunService").RenderStepped:Connect(function()
  13. -- Limit the maximum number of parts visible in the workspace
  14. local visiblePartsLimit = 100 -- Adjust this value based on your game's needs
  15. local visiblePartsCount = 0
  16.  
  17. for _, part in ipairs(game:GetService("Workspace"):GetDescendants()) do
  18. if part:IsA("BasePart") and part:IsInViewport() then
  19. visiblePartsCount = visiblePartsCount + 1
  20. if visiblePartsCount > visiblePartsLimit then
  21. part.Transparency = 999 -- Make parts transparent if they exceed the limit
  22. else
  23. part.Transparency = 0 -- Make parts visible if they are within the limit
  24. end
  25. end
  26. end
  27. end)
  28. end
  29.  
  30. optimizeGame()
  31.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement