So, I'm making this game, kind of like murder mystery, but based off of a game I play in real life. The script is supposed to change the text at the top of the screen to "Waiting for 2 players" when a player joins, but nothing changes. There isn't any output.
--please dont steal this
--variables--
local playercount = 0
local roundinprogress = false
local enoughplayers = false
--functions--
function announce(msg)
for i,v in pairs(game.Players:GetChildren()) do
v:WaitForChild("PlayerGui"):WaitForChild("status"):WaitForChild("TextLabel").Text = msg
end
end
function startround()
announce("Round starting!")
local number = math.random(1,#game.ReplicatedStorage.PlayersInGame)
local physco
for i,v in pairs(game.ReplicatedStorage.PlayersInGame:GetChildren()) do
if i == number then
physco = v
end
end
wait(3)
announce(physco.Value.." has been chosen to be the phsyco! Run from them!")
wait(3)
for i,v in pairs(game.Players:GetChildren()) do
end
end
--rest of the code--
announce("Waiting for 2 or more players.")
game.ReplicatedStorage.PlayersInGame.ChildAdded:Connect(function()
playercount = playercount+1
end)
while true do
wait(1)
if playercount >= 2 then
startround()
enoughplayers = true
else
enoughplayers = false
end
end
while true do
if roundinprogress == false then
for i,v in pairs(game.Players:GetChildren()) do
if not v.Character:FindFirstChild("beforeround") then
local ff = Instance.new("ForceField")
ff.Name = "beforeround"
ff.Parent = v.Character
end
end
else
for i,v in pairs(game.Players:GetChildren()) do
if v.Character:FindFirstChild("beforeround") then
v.Character.beforeround:Destroy()
end
end
end
end

1 comment
The 11th line is glitched. It's supposed to be: v:WaitForChild("PlayerGui"):WaitForChild("status"):WaitForChild("TextLabel").Text = msg