Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local loop = {}
- local loops = {}
- function loop:CreateLoop(name, waittype, func)
- loops[name] = {}
- loops[name]["running"] = false
- loops[name]["destroy"] = false
- loops[name]["func"] = spawn(function()
- while true do
- if waittype == "renderstep" then game:GetService("RunService").RenderStepped:Wait() else wait() end
- if loops[name]["running"] then
- func()
- end
- if loops[name]["destroy"] then
- loops[name] = nil
- break
- end
- end
- end)
- end
- function loop:RunLoop(name)
- if loops[name] then
- loops[name]["running"] = true
- end
- end
- function loop:StopLoop(name)
- if loops[name] then
- loops[name]["running"] = false
- end
- end
- function loop:DestroyLoop(name)
- if loops[name] then
- loops[name]["destroy"] = true
- end
- end
- function loop:GetRunningLoops()
- local looplist = {}
- for i, v in next, loops do
- if v["running"] then
- table.insert(looplist, i)
- end
- end
- return table.concat(looplist, ", ")
- end
- return loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement