[HELP!] Game Timeout!

So as you can see guys i’m a upcoming developer trying to surprise stickmasterluke with a game i’m making.

The name is call Master Disasters

I have everything read the only problem is when i put my script into a loop the script breaks but the client still runs

Examples:


Example
Timeout

So lets say i have 200 lines of code which i do i put it in a script so it can repeat when i do so it breaks is there a more organized way to loop games. Look at stickmasterluke’s game Survive The Natural Disaster For Instance It Is Looped In A Way I Want To Replicate That

Change it from while true do to while wait(.1) do

1 Like

You should add wait() to your script or you can use while wait() do

ok ill try that! :smiley: thanks for the feedback

What is this while true do loop nightmare? Anyways, I think you forgot to add some yielding. Without yielding, the code will be exhausted from high rate of looping.

wait() is the yielding.

I doubt you need to loop the entire thing all the time.

2 Likes

Can you explain what yielding is please?

Yielding in other words is for “pausing the thread”. The thread will stop and wait until time or for a signal.

Ok gotcha thanks for the help ill make sure to credit you in guys in my game for all the frustration i went through :smile:

It still doesnt work hmm dont know whats the problem

Like i put the wait() on it and its like it doesnt even run my script

Ugh, just forward the entire 200 lines of code with the loop. I believe I can make this more effective. Mind if you PM me if you believe this will drag on for too long?

Better not to, especially considering the context of the script’s purpose.
cc @Kensizo @Hexlinee

while true do
    -- 200 lines of code
    wait()
end

Make sure to add waits where appropriate. The game script is timing out because each iteration of your while loop is running too quickly. This is done to prevent Studio crashing, which was once a problem when while loops weren’t being properly handled in the past.

I checked the entire code and gave them the fixed solution. The loop is extremely useless and from what I know of the code there, was poor understanding of coding logic.

The loop was very expensive to maintain and some of the code were malformed from intended functionality. Especially that it kept attaching new connections to a listener.

1 Like

Its true fellas in my eyes the loop was useless aswell but atm thats all i could think of to finish the game lol xD