Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Lag Issues help?

Asked by 8 years ago

Is too much scripts running create lags? For example, if a script run without wait and not a loop script, will it create lag if all of them run at the same time?

2 answers

Log in to vote
2
Answered by 8 years ago

Yes, too many scripts running at the same time can cause too much lag. Roblox can only handle roughly 1,600,000 functions/calls per second(with a 1.6 GHz processor). That's 1.6 while true do loops running at the same time without wait. Note that this is approxamite.

0
one while loop with no wait crashes my game, and EVERERYBODY else's game. theCJarmy7 1293 — 8y
0
^ User#11440 120 — 8y
0
with no background processes at all connor12260311 383 — 7y
0
not even roblox or your os connor12260311 383 — 7y
Ad
Log in to vote
2
Answered by 8 years ago

Lag

Lag can be broken down, it does not just include scripts. The hole process from client-> server -> client will all produce latency.

From a scripting point simplifying the script may help. One of the most common things I see people doing is this:-

local someval = true
if someval == true then
    -- code block
end

since the if statement will only run if true why check it use this instead:-

local someval = true
if someval then
    -- code block
end

When code is ran it helps to keep in mind what is being done When And For How Long e.g. a simple loop:-

local i = 0
while true do
    local a = "???"
    i = i+ 1
    wait() -- wait is needed or it will freeze
end

Do you really want to create the variable "a" every loop?

local i = 0
local a = "???"
while true do   
    i = i+ 1
    wait() -- wait is needed or it will freeze
end

Most games deal with lag by masking or hiding it e.g. using local parts to make the game seem responsive. Roblox has an article about it here and the game is un-copy locked.

Who Does What

server:- I will do it, client:- I could do it?

This depends on what game you are creating but if its safe to do locally then you should make the code local, share the workload so its not just the server doing the processing.

why not just add your own lag for testing?

Using the IncommingReplicationLag will allow Roblox Studio to mimic lag (for testing only) as a lot of scripts may fail because they have not checked if the object exists. This is useful for all aspects of your game not just loading in a new player.

Use the correct object in the correct place

Remote Function Lag

When using FilteringEnabled events and or function are needed to send requests from local script to the server.

A remote function will have a call back from the server e.g. localscript request -> server -> localscript. This increases the network traffic so it is also create lag.

In short always check what code does and what it effect, so read the API

Advanced

Don't wait just do approach

Again is script waiting for something else to be done wastes time when it could be done now Threading allows execution of the code without waiting for the predecessor to finish. We do not use the result of the process so just continue to run code.

How to check and look for lag

In Roblox studio there are tools available to look for lag in the game like:-

Diagnostics

Script_Performance

Other links

an-optimization-for-lua-scripts

0
Great explanation! User#11440 120 — 8y
0
pls comment is ive left any thing out User#5423 17 — 8y
0
forgot to add in filtering/remote function lag User#5423 17 — 8y
0
If you have a finished script and don't need to edit it again ( although you can ) then you can always use this plugin to reduce amount of code and execution time :P, link for it: https://www.roblox.com/Stravant-Minify-Beautify-Beta-item?id=197760456 disassembling 48 — 8y
0
this should not reduce execution time , this is mainly used for script hideing so the end user cannot easily work out what a script does. This would be good for local script use. User#5423 17 — 8y

Answer this question