You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I have heard that while loops can be inefficient, so I’m looking for an alternative.
What is the issue?while loops can degrade performance, so I wanna see if there’s any alternatives.
Hey developers! I’m looking to make more performant code, without using while task.wait() loops, issue is, I need specific yield times for different scenarios, so I may utilize different numbers for the loop, this would automatically rule out using events such as Heartbeat or Renderstepped, as I need the loop to run with a specific time delay each time.
For what you are saying you can still delay your code using Heartbeat or Renderstepped. Having while loops is fine, having many while loops running at the same time is bad. But you can have specific functions or tasks delays with Runservice by using tick().
Depending on what you want to need you can just do
local lastTask = tick()
local interval = 5 --delay time
runService.Heartbeat:Connect(function()
if tick() - lastTask > interval then
lastTask = tick()
--do task
end
end)