Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

{Simple Script} Need Help?

Asked by 9 years ago
M = Instance.new("Message")
M.Parent = Workspace

if game.Players.Numplayers >2 then
M.Text = "Waiting For More Players"
end
end

Why Will This Not Work ?

0
I fixed the Message spam. alphawolvess 1784 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

I would believe you problem is it only checks once. You could use a loop to check to see how many players there are. Also, you should have told us more information like what's going wrong? Is their no Message, etc. Also, you have an extra end

Assuming this is a regular Script, I will show you how to make this work by using a Loop so you may check over and over if their's enough players.

while true do
    wait()
    if game.Players.NumPlayers < 2 then
        if game.Workspace:FindFirstChild("Message") then
            print("Message Exist")
        else
            local M = Instance.new("Message", game.Workspace)
            M.Text = "Waiting For More Players"
        end
    else
        wait()
        game.Workspace.Message:Destroy()
    end
end

You'll notice I did a lot different then you did. I am removing the Message when their's more than 2 players, also I changed my sign to less than because I believe that's what you wanted to do. Now I made the Message inside the script so if more players leave, and there will only be 2 or 1 players left, the message will come back, but if there is more than 2, the message will come back. This is an endless loop!

0
This worked However It Creates Around 50 Messages! jblade73 18 — 9y
1
Because it Looped. XToonLinkX123 580 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

First of all, you have too many ends Second, line 4 is basically saying if there are more than 2 people then blah blah blah. Change line 4 to this:

if game.Players.NumPlayers < 2 then

That is saying if NumPlayers is smaller than 2.

Please upvote and accept my answer if this helped!

Answer this question