Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why Doesn't It Change The Text?

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

0

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

2 answers

✓ Accepted answer

I don't see problems, make this to a LocalScript I guess.

2 comments

0

I’ll accept your answer because I did make it a local script, but that isn’t what fixed it. Thanks for trying!

0

Thank you :)

I just figured out all I needed to do was run wait(5) before running the script... omg im so dumb. Thanks for trying to answer though!

This discussion is preserved as it was. New answers, comments, and votes are closed.