Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Running a while loop while using module script at the same time?

Asked by 6 years ago

ModuleScript

local module = {}

local replicatedStorage = game:GetService("ReplicatedStorage")
local valuesFolder = replicatedStorage:WaitForChild("ValuesFolder")
local timerValue = valuesFolder:WaitForChild("TimerValue")

function module.deathmatch()
    print("Deathmatch")
    wait(timerValue.Value)
    -- Do gamemode stuff
end

return module

Main Script

gamemodeScript = require(selectedGamemode)
gamemodeScript.deathmatch()

-- Next

The module runs perfectly, but I don't know how to run a while loop that counts down while running the modules code. I haven't written all the modules code but it's gonna have code which checks when players die and adds points to teams. Thats irrelevant right now. I just need the module script to run for the set period of time and have a timer counting down while the module does the other stuff. And when that timer is up it continues onto the next step of code in the main script and the module script stops working until it is called again. Would a coroutine be used for this? If so, how would I implement it.

0
Maybe have a "spawn(function() end)"? its like having 2 scripts running but runs at the same time UltraUnitMode 419 — 6y

Answer this question