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

Why is this while statement not doing the correct thing?

Asked by
chasedig1 115
7 years ago

This while statement is doing the incorrect thing, it is giving me no errors, yet says that the children of the object are zero when that is not true. Full code:

01--Don't change the name of Cannon, or anything else within the Cannon model, unless you're willing to rewrite the script.
02local dispenser = script.Parent
03local dispensingPosition = workspace.DoughDispenser.dispenserarea
04local Holder = Instance.new("Model", game.Workspace.Containers)
05Holder.Name = "DoughHolder"
06--Gets the current amount of children (used later in a while statement) in the container.
07local currentAmount = #workspace.Containers.DoughHolder:GetChildren()
08print (currentAmount)
09while game.ServerStorage.DoughValue.Value >= 1 and currentAmount <= 2 do
10 
11    game.ServerStorage.DoughValue.Value = game.ServerStorage.DoughValue.Value - 1
12local Copy = game.ServerStorage.DoughPart:Clone()
13Copy.Parent = game.Workspace.Containers.DoughHolder
14Copy.Position = dispensingPosition.Position
15Copy.Velocity = Vector3.new(0,0,5)
16wait(2)
17end

Problematic Code:

1and currentAmount <= 2 do

Help?

0
Did line 8 print the correct amount of children? lesliesoon 86 — 7y
0
No. chasedig1 115 — 7y

Answer this question