Advertisement
0xHumanoid

Untitled

Sep 17th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. local loop = {}
  2. local loops = {}
  3. function loop:CreateLoop(name, waittype, func)
  4. loops[name] = {}
  5. loops[name]["running"] = false
  6. loops[name]["destroy"] = false
  7. loops[name]["func"] = spawn(function()
  8. while true do
  9. if waittype == "renderstep" then game:GetService("RunService").RenderStepped:Wait() else wait() end
  10. if loops[name]["running"] then
  11. func()
  12. end
  13. if loops[name]["destroy"] then
  14. loops[name] = nil
  15. break
  16. end
  17. end
  18. end)
  19. end
  20. function loop:RunLoop(name)
  21. if loops[name] then
  22. loops[name]["running"] = true
  23. end
  24. end
  25. function loop:StopLoop(name)
  26. if loops[name] then
  27. loops[name]["running"] = false
  28. end
  29. end
  30. function loop:DestroyLoop(name)
  31. if loops[name] then
  32. loops[name]["destroy"] = true
  33. end
  34. end
  35. function loop:GetRunningLoops()
  36. local looplist = {}
  37. for i, v in next, loops do
  38. if v["running"] then
  39. table.insert(looplist, i)
  40. end
  41. end
  42. return table.concat(looplist, ", ")
  43. end
  44. return loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement