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

Strange this isnt working? Simple Concatenation Loop

Asked by 6 years ago
Edited 6 years ago
while true do()
    StarterMax = 10
    sc = 0
        function StarterLoop()
            if sc <= StarterMax then
                StarterPatchGrow()
                sc = sc + 1
                print(sc)
            end
        end
    wait(1)
end

function StarterPatchGrow() -- Starter Patch Generation
    math.randomseed(tick())
    local _x = UnnamedModels:GetChildren()
    local x = _x[math.random(1,#_x-2)]
    local _y=x:GetChildren()
    local y = _y[math.random(1,#_y)]
    local Value = GetValue(y,"Unnamed")
    local RealModel = y:Clone()
    RealModel.Parent = StarterPatch.SpawnedPumpkins
    RealModel.Position = Vector3.new(math.random(StarterPatch.MinX.Value,StarterPatch.MaxX.Value),math.random(StarterPatch.MinY.Value,StarterPatch.MaxY.Value),math.random(StarterPatch.MinZ.Value,StarterPatch.MaxZ.Value))
    local PumpkinLabel = game.ReplicatedStorage.LoadModels.UI.PumpkinLabel:Clone()
    PumpkinLabel.Adornee=RealModel
    PumpkinLabel.Parent=RealModel
    PumpkinLabel.Frame.Nickname.Text = 'Name : '..RealModel.Name
    PumpkinLabel.Frame.Rarity.Text = 'Rarity : '..x.Name
    PumpkinLabel.Frame.PumpkinValue.Text = 'Value : '..Value
end

The loop will continue to print 1, anyone know why?

0
I'm not good at scripting so I'll just ask; why += and not just = ? Spjureeedd 385 — 6y
0
You need to include "sc" in the assignment. Don't use a compound assignment so "sc = sc + 1" Cousin_Potato 129 — 6y
0
Even when I only include sc = sc + 1, it prints 1 every time still. Simulants 52 — 6y
0
Is StarterMax a variable? Because you never use it Spjureeedd 385 — 6y
View all comments (4 more)
0
What's the rest of the code? Your function doesn't have a loop. Cousin_Potato 129 — 6y
0
Does it print 1 only one time or does it repeat it? Spjureeedd 385 — 6y
0
You're resetting sc=0 at the top of the loop everytime. Put the "sc = 0" outside of the while loop. Cousin_Potato 129 — 6y
0
Ahhhhhhhhhhhhhhhhhhhhhh thanks Simulants 52 — 6y

1 answer

Log in to vote
-1
Answered by 6 years ago
local sc = 0

while true do

    print(sc)
    sc = sc + 1

    wait(1)
end
0
-1 for not giving an explanation at all. If you know the answer to a question, you should explain to the OP what was wrong with their attempt, and why your answer works. User#19524 175 — 6y
0
hold the minute to the up, what does this mean again? speedyfox66 237 — 6y
Ad

Answer this question