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”
repeat
wait()
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
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
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"
end
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
end
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.