local A = game.workspace.Part
local B = game.workspace.Baseplate
local BlocksAllowed = 10
local function Initialize_A()
A.BrickColor = BrickColor.Random()
local ACopy = A:Clone()
ACopy.Parent = game.workspace
end
wait(2)
while true do
Initialize_A()
wait(1)
print("check")
repeat Initialize_A()
until Initialize_A() > 5
end
COMMUNITY QUESTION
Just practicing my Lua, but I need help. Why does my repeat...until work?
1 answer
i don't know why you are trying to make a function a variable. you can easily solve this by calling the function.
local A = game.workspace.Part
local B = game.workspace.Baseplate
local BlocksAllowed = 10
local AmountOfClones = 0
function Initialize_A()
A.BrickColor = BrickColor.Random()
local ACopy = A:Clone()
ACopy.Parent = game.workspace
end
wait(2)
while true do
Initialize_A()
wait(1)
print("check")
repeat
Initialize_A()
AmountOfClones = AmountOfClones + 1
until AmountOfClones == 5
if AmountOfClones == 5 then
break
end
end
I havn't tried it yet, but it looks to be clear!
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
An easy fix for experienced scripters
Idk what you're trying to do so here's this x=0 repeat x=x+1 game.Workspace.BrickColor=BrickColor.Random() until x>=5
The goal I was trying to accomplish was to clone a brick, that changes colors with the original brick, but stops after a certain amount of bricks. It's not a script for any serious game play, just practice.