Scripting problem

Hi Guys, I encountered a problem with my script. I’m making a status for my game for the players to see and I want to it to change from “Waiting For Enough Players” to “Intermission”. However, when I play the status does change but it changes to 0 not intermission, here is the code

Status.Value = “Waiting For Enough Players”



until game.Players.NumPlayers >= 2

Status.Value = “Intermission”

Before it said it was a infinite loop but I fixed that. No error code comes up on the output so I can’t pinpoint why it isin’t working


use the code tag for code (it is ```)

first off, add a print statement to make sure this code is running correctly.
Second, check if theres any other code thats setting it to 0

1 Like

What does represent the Status instance in your script? Is it a StringValue?


Just checked, I accidently put it as a intvalue instead of a stringvalue. That probably explains why it is 0, rookie mistake by me lol


fixed it don’t worry anymore about this post guys :slight_smile:

Of course, it has to be the anchor point of your struggle.
Try your script and make sure the StringValue is located in an area where Server and Client can both have access, otherwise it won’t work. Remember Client can’t change values for the Server, else it won’t be replicated to other Clients. Your script has to be a ServerScript and located in ServerScriptService or Workspace. Your StringValue can be a Child of your ServerScript, for instance.

Yep, I have the script in ServerScriptService but I have my StringValue in ReplicatedStorage, it seems to be working as it has changed to intermission. I’m a new scripter so simple mistakes will be easily made by me lol

That’s another possibility which will perfectly work. In fact, ReplicatedStorage is also an area which enable Server and Client to work together.

1 Like

I have a quick question, if I wanted to make the server choose the maps for me would I need to put the maps into a table?

local maps = ReplicatedStorage.Maps:GetChildren() -- or wherever you store your maps

local randomMap = maps[math.random(1, #maps)]
1 Like

I’m not a professional scripter either, but I recently began scripting an entire round system, with timer, steps (Intermission, Voting, Starting, Round, Ending) and I did put my maps into an array.

In fact, my maps are all Models, and they are grouped into a Folder. That’s an extract of what I’ve scripted:

-- pathway to your map Folder (if they are in a Folder)
local maps_folder = game:GetService("Workspace"):FindFirstChild("Maps")
-- initialization of the array, which is empty at the beginning
local maps = {}
	for _, map in ipairs(maps_folder:GetChildren()) do
		maps[#maps+1] = map -- we add each map of the folder in the array "maps"
	for i = 1, 3, 1 do -- we choose 3 maps that we randomly pick and we put them in another array (I needed it because I chose multiple maps)
		local current_random_map = math.random(#maps)
		randomly_chosen_maps[#randomly_chosen_maps+1] = maps[current_random_map]
		table.remove(maps, current_random_map) -- we remove the chosen map from the previous array to be sure it cannot be chosen multiple times

This ServerScript enables the Server to choose 3 random maps across my maps folder.
I needed to create an array because my script doesn’t choose 1 map, but 3. And I didn’t want a map to be able to be chosen multiple times.