Help with basic Murder Mystery game script

Hello developers :grin:
(Please excuse the poor code, I am currently trying to learn it from basics…)
I have started on making the idea of a murder mystery type game a few minutes ago, and scripted this. For some reason is is not outputting these basic commands. Is you need more info to help me, the script is located in ScreenGui, because I wanted to alter the TextLabel with this script. It is also just a normal script… Here is it below :arrow_down:

local plrs = game.Players
local ready = false

while true do
	local num = plrs:GetChildren()
	if num > 1 then
		local ready = true
	else
		local ready = false
	end
end

if ready == true then
	script.Parent.TextLabel.Text = "Enough players!"
	wait(1)
	script.Parent.TextLabel.Text = "Enough players! Starting in 3..."
	wait(1)
	script.Parent.TextLabel.Text = "Enough players! Starting in 2..."
	wait(1)
	script.Parent.TextLabel.Text = "Enough players! Starting in 1..."
	wait(1)
	script.Parent.TextLabel.Text = "Round starting."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting.."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting..."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting.."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting..."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting."
	wait(0.5)
	script.Parent.TextLabel.Text = "Round starting.."
end


if ready == false then
	repeat
	script.Parent.TextLabel.Text = "Wait for more players."
	wait(1)
	script.Parent.TextLabel.Text = "Wait for more players.."
	wait(1)
	script.Parent.TextLabel.Text = "Wait for more players..."
		wait(1)
		until ready == true
end

So sorry if this is me being annoying, and this is obvious :roll_eyes: I was also thinking, maybe it might be that the script is positioned in ScreenGui :question: :question: :question:

1 Like

I saw your first mistake, local num = plrs: GetChildren () this part is didn’t sends an int value. You should do it like local num = #plrs: GetChildren ()

Because # is converts children’s to their count as int

Your 2. Mistake is until is in wrong place, I think it’s because devforum bug.

1 Like

Thanks! I will try that right away!

2 Likes

No sorry, it still won’t output the ‘Wait for more players…’ text

1 Like

Do you get any error or information? I can’t see another mistake, try look at

I’m at mobile so I can’t write examples fine.

1 Like

Ok thanks I will look at that. No I don’t think I get any errors, but it won’t output it???

1 Like

I got the error right now! Problem is while loop is infitine and it’s blocks other codes. Make is coroutine.resume(coroutine.create(while true do local num = #plrs:GetPlayers() if num > 1 then local ready = true else local ready = false end end))

I’m at mobile so it’s maybe has mistakes, you can fix that.

Note: fixed again it’s now should works

1 Like

Have I layed it out correctly?

local plrs = game.Players
local ready = false

while true do
	coroutine.continue(coroutine.create(
		while true do
		local num = #plrs:GetPlayers()
		if num > 1 then
			local ready = true 
		else 
			local ready = false 
			
		end
	end)

thanks!

1 Like

Make coroutine.continue like coroutine.resume, then it’s will work.

1 Like

Like this?

local plrs = game.Players
local ready = false

while true do
	coroutine.resume(coroutine.create(
		while true do
		local num = #plrs:GetPlayers()
		if num > 1 then
			local ready = true 
		else 
			local ready = false 
			
		end
	end)
1 Like

Yes! That’s will should work, if it will not work, try put another ) at end)

1 Like

It still doesn’t work. I don’t know what is going on

1 Like

It’s underlining the word

while

in blue

2 Likes

Do you get any errors? That’s maybe about I writed that wrong.

1 Like

Oh problem is you writed code like wrong position, use coroutine and write it again without copying.

1 Like

Ok, I’ll see if that will work

1 Like

Here is code I writed in a program

coroutine.resume(coroutine.create(function( while true do; local num = #plrs:GetPlayers() if num > 2 then; ready = true else; ready = false end end))

You not need play with it just copy paste and run code

1 Like

I’ve layed it out like this - still not working…

while true do
	coroutine.resume(coroutine.create)
	while true do
		local num = #plrs:GetPlayers()
		if num > 1 then
			local ready = true
		else
			local ready = false
		end
		end
	end
1 Like

Look the new post, it’s because I forget add function thing just copy paste and do not play with code just run the game

1 Like

I entered this and didn’t play with it…

coroutine.resume(coroutine.create(function( while true do; local num = #plrs:GetPlayers() if num < 2 then; ready = true else; ready = false end))
1 Like