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

Just practicing my Lua, but I need help. Why does my repeat...until work?

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

3 comments

0

An easy fix for experienced scripters

0

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

0

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.

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.