Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Strange this isnt working? Simple Concatenation Loop

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?

8 comments

0

I'm not good at scripting so I'll just ask; why += and not just = ?

0

You need to include "sc" in the assignment. Don't use a compound assignment so "sc = sc + 1"

0

Even when I only include sc = sc + 1, it prints 1 every time still.

0

Is StarterMax a variable? Because you never use it

0

What's the rest of the code? Your function doesn't have a loop.

0

Does it print 1 only one time or does it repeat it?

0

You're resetting sc=0 at the top of the loop everytime. Put the "sc = 0" outside of the while loop.

0

Ahhhhhhhhhhhhhhhhhhhhhh thanks

1 answer

✓ Accepted answer
local sc = 0

while true do
	
	print(sc)
	sc = sc + 1
	
	wait(1)
end

2 comments

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.

0

hold the minute to the up, what does this mean again?

This discussion is preserved as it was. New answers, comments, and votes are closed.