I am making a round based framework, so i am using a module script to store all the states, status,etc.
so this is the code i have used-
local module = require(game.Workspace.ModuleScript)
local gamestate = module.gamestate
local status = module.Status
local maps = module.maps
local modes = module.gamemodes
if gamestate == "." or gamestate == "Match Ended" then
local Countdown = 20 -- intermission, make this as long as you want
print("")
repeat wait(1)
Countdown = Countdown - 1
module.gamestate = "Intermission"
module.status= 'Intermission : '..Countdown
print(module.status)
until Countdown <= 0
print("Swapping to vote")
module.status = "Vote Now"
module.gamestate = "Vote"
end
its not printing nor is the status working the gamestate changing is working tho
edit 1:@Angiris_treecreeper helped me with the module values not changing part but everything inside the repeat until isnt working
nor are the prints
edit 2:grammar
1 Like
If you’re trying to change the value from inside the Module Script, I’m pretty sure that Module Scripts can’t run code by themselves.
the script tht i gave in the post is a server script the module is somewhere else
Yea but are you trying to change the string from inside the Module?
wdym like the variable is under the module and in the server script im requiring the module and in a repeat until loop i am changing the value
Take a look through these examples and test the scripts if you’d like to help your understanding. It should help you fix your problem.
MODULE SCRIPT
local module = {}
module.TestStringValue = "Hello There!"
function module.EditTestString(newString)
module.TestStringValue = newString
end
return module
TESTING SCRIPT
local ValueTestingModule = require(script.ValueTesting)
print("Printing access to string through module: " .. ValueTestingModule.TestStringValue)
local testString = ValueTestingModule.TestStringValue
print("Printing the local TestString " .. testString)
testString = "Edited String"
print("Print after editing the local variable storing the string " .. testString .. " and the module stirng " .. ValueTestingModule.TestStringValue)
ValueTestingModule.TestStringValue = "Edited through the module.TestStringValue"
print("Editing using the module instead " .. ValueTestingModule.TestStringValue)
ValueTestingModule.EditTestString("Edited by module using function")
print("Editing using the module function " .. ValueTestingModule.TestStringValue)
OUTPUTS

As you can see, if you attempt to store a reference to the module.Variable then it actually just stores the value of that variable.
e.g.
local storedVariable = module.Variable
print(storedVariable) --Will print storedVariable, not module.Variable
storedVariable = "New String Here"
This is just editing the value of storedVariable, not module.Variable
Instead you need to store a link to the module e.g.
local module = require(ModuleLocationHere)
module.Variable = "New String Here"
or make a function inside the module script to edit the variable as shown in the example.
Hope this helps 
1 Like
tht did help but for some reason nothing inside the repeat until loop is working
Where does it get to within the program?. Try adding some prints to see where it gets stuck
the entire repeat until loop like literally not even 1 part of the repeat loop is working (check the edits i made to the to the 1st post/start of thread)
Okay, I’ve had a look through and made a few small edits.
local module = require(game.Workspace.ModuleScript)
if module.gamestate == "." or module.gamestate == "Match Ended" then --Use module.gamestate to make sure you have most up to date version
local Countdown = 20 -- intermission, make this as long as you want
print("")
repeat wait(1)
Countdown = Countdown - 1
module.gamestate = "Intermission"
module.status= 'Intermission : '..Countdown -- Should consider using " to be consistant with line above
--module.status = "Intermission : " .. Countdown
print(module.status)
until Countdown <= 0
print("Swapping to vote")
module.status = "Vote Now"
module.gamestate = "Vote"
end
Also does it ever pass this condition?
if gamestate == "." or gamestate == "Match Ended" then
1 Like
yes the prints after the until are coming
thank u it worked but uuh now i have a problem in my gui

the TextLabel.Text aint updating tho
Yeah, I think this is the same problem as before
script.Parent.TextLabel.Text = module.Status
This is not setting it to the reference of module.Status, its just setting it to the current value.
You could update this in a loop which should fix the problem
EXAMPLE
local module = require(game.Workspace.ModuleScript)
local TextLabel = script.Parent.TextLabel
local oldModuleStatus = module.Status
TextLabel.Text = module.Status
local StatusUpdate = coroutine.create(function()
while true do
if oldModuleStatus ~= module.Status then
oldModuleStatus = module.Status
TextLabel.Text = module.Status
end
wait(0.1) --This number can be as small or as large as you like however 10 times a second is probably more than enough for a piece of text
end
end)
coroutine.resume(StatusUpdate)
This way, whenever module.Status is updated, the text will get updated to
1 Like