Text Label won't change

While working on my project, I have stumbled across a big problem. When in run mode, the text labels work perfectly. But when I play solo, it is stuck. It is stuck on “Choosing Map”

The script is long but here you go:
–[[Chooses a random map using tables
Made by RinxfulROBLOX
12/19/2020, PUT MAPS IN LIGHTING FIRST, PUT SCREEN GUI IN STARTERGUI, PUT SCRIPT INSIDE WORKSPACE]]
local map1 = game.Lighting.Bridge
local map2 = game.Lighting.Forest
local map3 = game.Lighting.Desert
local map4 = game.Lighting.City
local mapText = game.StarterGui.ScreenGui.TextLabel --Whatever map is chosen, the name will be printed here
textIntValue = mapText.IntegerValue.Value
textStringValue = mapText.StringValue.Value

local maps = {map1, map2, map3, map4}

function choseRandomMap()
textStringValue = “Choosing Map…”
mapText.Text = textStringValue
wait(20)
currentMap = maps[math.random(1, #maps)]-- Gets 1 random map out of # of maps, which is 4
currentMap.Parent = game.Workspace
textStringValue = currentMap.Name… " has been chosen!"
mapText.Text = textStringValue
–Getting players on the map
wait(5)
local players= {}
local target = currentMap.SpawnLocation

wait(20)
for i,v in pairs(game.Players:GetChildren())do
	table.insert(players, v)
end

for i,v in pairs(players)do
	v.Character:MoveTo(target.Position)
end
wait(5)
round()

end

–Round
local roundTime = 30
function round()
for i = roundTime, 0, -1 do – Every second, roundTime will decrease by 1, once it reaches 0, round will end
textIntValue = i
mapText.Text = textIntValue
wait(1)
if i == 0 then
textStringValue = “Round ended!”
mapText.Text = textStringValue
wait(5)
textStringValue = “Starting new round!”
mapText.Text = textStringValue
removeCurrentMap()
wait(5)
choseRandomMap() – New round begins
end
end
end

function removeCurrentMap()
currentMap.Parent = game.Lighting
end

choseRandomMap()

1 Like

You can not use the StarterGui to change text. This is because, in runtime, all GUI’s that are in there are cloned to the client’s PlayerGui. Instead, you need to have a client sided script that changes the text. Here are some options for you to explore:

  1. Possibly have a string value in ReplicatedStorage and change that instead so it replicates to all clients and they can pick up on the property changed signal of the value.

  2. Fire all clients with the status value whenever it changes so they can update it for themselves

5 Likes

Have you tried to add a LocalScript inside the Label and find the StringValue and set the label text in the LocalScript? It is a more efficient way of doing this. Also “StarterGui” is a replicated service. I would not recommend using this to locate a GUI.

Thank you for the help! I will try this

1 Like

No problem :slightly_smiling_face: Good luck buddy

Thank you for the help! I will take this into account aswell

1 Like