now if i want to put a countdown in the script for matchmaking purposes
function COOLDOWN()
for i = script.COOLDOWN_TIME.Value, 1, -1 do
script.BUTTON.Value.Text = "Cooldown "..i
script.BUTTON.Value.BackgroundColor3 = Color3.fromRGB(175, 0, 3)
wait(1)
end
end
then the script is sadly not responsive during that period of time, but i need it to be responsive in order to implement a voting system. how can i do that?
i dont want the function code to be inside another function, i want the matchmaking to be called seperately (be a seperate function)
task.spawn(function()
for i = script.COOLDOWN_TIME.Value, 1, -1 do
script.BUTTON.Value.Text = "Cooldown "..i
script.BUTTON.Value.BackgroundColor3 = Color3.fromRGB(175, 0, 3)
task.wait(1)
end
end)
Task.spawn creates another thread process on the CPU, and it’s asynchronous meaning it runs at a difference timing relative to the rest of the script.
You can also just use task.wait() since it should just wait for that function, but if that doesn’t work task.spawn() will.