can anybody want to tell me how exactly task.synchronize works and when i should use it
This may be helpful:
Edit:
Not really sure if it is helpful or not as i do not know what it is
task.synchronize is part of a few functions that are related to parallel and serial code executions. Parallel means several code blocks can run all at once, serial means they’ll run one by one depending on their order. For example:
while task.wait(1) do
print("Block A")
end
while task.wait(1) do
print("Block B")
end
In this scenario, because they’re running serially (one by one) Block B would never print because Block A is an infinite loop, never stops. However, with the use of coroutines or task.spawn
we could make them run at the same time:
task.spawn(function()
while task.wait(1) do
print("Block A")
end
end)
task.spawn(function()
while task.wait(1) do
print("Block B")
end
end)
These are running in parallel, so they will both print at the same time. I’ve personally never used task.desynchronize
or task.synchronize
, but Suphi Kaner has a video on it. At a surface level, I would assume they do the same thing as task.spawn or a coroutine, but there’s most likely a few differences between them.
Edit: Just realized what I wrote is definitely off-topic, but still valuable if you didn’t know them. I’m sorry I couldn’t explain better, but the linked video does a good job at explaining
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.