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

Having trouble learning 'and' conditions, help?

Asked by
yurhomi10 192
11 years ago

nothing is working, only prints 'whats wrong?' in the output...

01running = false
02enough = game.Players.NumPlayers
03 
04if (running == false and enough >= 1) then
05    running = true
06    while true do
07        m = Instance.new("Message", Workspace)
08        m.Text = "Now starting a new game!"
09        wait(1)
10        m:Destroy()
11        for i, v in pairs(game.Players:GetChildren()) do
12            if v.Character.BoolValue.Value == true then
13                print(v.Name .. " has been found")
14                v.Character.Torso.CFrame = Vector3.new(10,10,10)
15            end
View all 21 lines...

4 answers

Log in to vote
0
Answered by 11 years ago

"Most likely the script loads before game.Players.NumPlayers changes to 1 because the server is started and scripts are run before the client is connected to it." - 1Waffle1

1game.Players.PlayerAdded:connect(function(plr)
2    if (running == false and enough >= game.Players.NumPlayers) then
3        --etc.

This will let it check every time a player joins to see if there are enough players.

Ad
Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
11 years ago

Most likely the script loads before game.Players.NumPlayers changes to 1 because the server is started and scripts are run before the client is connected to it.

0
alright, lemme try something yurhomi10 192 — 11y
0
That really doesn't help because you only explained the problem, which you do explain, but it is something pretty confusing to think of the first time. If you could, I would suggest also posting a solution. User#2 0 — 11y
Log in to vote
0
Answered by 11 years ago

Yeah, the script loads before NumPlayers is updated with 1 as it's value. Try asking if enough is greater than (not greater than or equal to) 0. However, you should put that into a looped wait with that set as the condition if you want it to wait until there are enough players.

Log in to vote
-1
Answered by 11 years ago

ddd

Answer this question