You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make this function I created to be non-yielding aka run alongside another function.
What is the issue? Include screenshots / videos if possible!
function dreamer()
local players = teams.Kid:GetPlayers()
while dreamTime > 0 do
dreamTime = dreamTime - 1
wait(1)
end
for i, v in pairs(players) do
v.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Dream_End.CFrame
end
end
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve done many google and dev hub searches and can only find the opposite of what I’m looking for.
function dreamer()
local players = teams.Kid:GetPlayers()
coroutine.resume(coroutine.create(function()
while dreamTime > 0 do
dreamTime = dreamTime - 1
wait(1)
end
end)
for i, v in pairs(players) do
v.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Dream_End.CFrame
end
end
The difference in using coroutine.wrap is that it runs the code immediately when called and only continues after hitting a yield within the function. Spawn will schedule the function to start at some time in the future, possibly with a yield. It runs the code following the spawn call before the code called with spawn. Using coroutine.wrap is ideal in most cases.