Delete please

I get stuck in “Awaiting script” on my server.
I have looked at the other topics but i dont think this is the same problem.
I know for a fact that it is this code that is the problem beacuse i tried starting the server with this script turned off, and then i can join and no bugs. But when i try to join the server with this script active then i get stuck in Awaiting scripts.

No errors, not in f8 and not in console.
I have tried to remove things from the code to but it still does not work.

This is the code:

Hello, you need to put the Citizen.Wait(sleep) in the while loop. Atm it’s just after it (at the end of the file).

1 Like

Thank you!

1 Like

You’re welcome :slight_smile:

when using while loops or threads in your code, its important to prevent them from running indefinitely which can cause issues such as freezing or unresponsiveness.

To do this, you can implement one of the following approaches:

  1. Sleep: one way to prevent an infinite loop is to add a sleep statement inside the loop, this pauses the loop for a specified amount of time, allowing other threads or scripts to execute in the meantime, ex:
while true do
  -- do something
  Citizen.Wait(100) -- pause the loop for 100 ms
end
  1. Break: another approach is to add a break to the loop, which stops the loop from running when a certain condition is met, ex:
while true do
  -- do something
  if some_condition then
    break
  end
end

@CainenotAble what ya think?

1 Like