Question on automation for a Wall Jump/ Wall Flick game

I’ve been making my wall jump/wall flick game for a while, but I’ve ran into a issue, it takes way too much time to do the method I have in place for it. my stages are in a folder called stages and are named with a number co-responding to their appropriate stage.
This is how I have been sizing them as it takes to long to use properties

local wj = game.Workspace["Lava Wall Jump"]
wj.kp1.Size =,0,0.1)
wj.kp2.Size =,0,0.2)
wj.kp3.Size =,0,0.3)
wj.kp4.Size =,0,0.4)
wj.kp5.Size =,0,0.5)
wj.kp6.Size =,0,0.6)
wj.kp7.Size =,0,0.7)
wj.kp8.Size =,0,0.8)
wj.kp9.Size =,0,0.9)
wj.kp10.Size =,0,1)
wj.kp11.Size =,0,1.1)
wj.kp12.Size =,0,1.2)
wj.kp13.Size =,0,1.3)
wj.kp14.Size =,0,1.4)
wj.kp15.Size =,0,1.5)
wj.kp16.Size =,0,1.6)
wj.kp17.Size =,0,1.7)
wj.kp18.Size =,0,1.8)
wj.kp19.Size =,0,1.9)
wj.kp20.Size =,0,2)
wj.kp21.Size =,0,2.1)
wj.kp22.Size =,0,2.2)
wj.kp23.Size =,0,2.3)
wj.kp24.Size =,0,2.4)
wj.kp25.Size =,0,2.5)
wj.kp26.Size =,0,2.6)
wj.kp27.Size =,0,2.7)
wj.kp28.Size =,0,2.8)
wj.kp29.Size =,0,2.9)
wj.kp30.Size =,0,3)
wj.kp31.Size =,0,3.1)
wj.kp32.Size =,0,3.2)

individually naming and writing more code to corespond with each new stage I add is becoming a painstakingly slow process, does anyone know how I can possibly automate this?

1 Like

for loops, you can just iterae through all children of an object, and apply the corresponding data to each of them.

To grab all Children, you would use the Function :GetChildren() on the object you want to grab the children from, you can then utilize the for loop to iterate though the objects, while adding .1 while you iterate:

local children = example:GetChildren() -- grabs all children

-- i means index, it can be the number/order the object is in, or the name of it
-- v means value, what the  index holds

for i,v in children do
    -- this will iterate through all objects in this table, you can then add .1
    -- when you are applying this data, like so:
    x += .1 -- I recommend making a variable prior to looping

    v.Size +=,0,x) -- adds x to the current value
    -- (x += y) is the exact same as doing (x = x + y) in a simple form

However keep in mind that the objects may not be the correct order you want them to be in, so you may need to sort them based on their name, or the number given.


Make the size a variable, then use a for loop and add 0.1 each time.

How will I sort through all of the children of the model that my jumps are in?

1 Like
for i, v in pairs(wj:GetChildren()) do

How would I sort them based on their name?, it has the letters kp with a corresponding numerical digit based on its stage

1 Like

Something like this should work.

local wj = game.Workspace["Lava Wall Jump"]
local size = 0

for i, v in pairs(wj:GetChildren()) do
	v.Size +=,0,size)
	size += 0.1
1 Like


Normally it shouldn’t happen, and you wouldn’t need to do this, but if you are using objects that need to be applied in a specific order, then you can do that, as it may be applied incorrectly, however here because they are all in number order, it should work as intended, but if you are applying numbers based off the place they are in (ex: kp30 to kp35), you can take out the kp part of the name, and then divide by 10, which if you have 1, dividing by 10 will have it be 0.1, and so on.

To do this, you can utilize string.sub to take apart the name, and then apply the number, I’ll show you how:

local name = "kp25" -- kp25 is 25th with the parts we have

local x = string.sub(name, 3, #name)
-- string.sub works by cutting off part of the string given, 
-- and returning the result, the first argument is the string
-- you want to change, which here is 'name'
-- The Second is the starting point, which is where we will cut kp
-- we will cut off at character 3 which is "2" in this string
-- this will remove "kp" from the string, the next argument is where
-- we will cut off at the end of the string, which should be the total
-- size of the string, we can get this number by using the # operator on
-- the string, which will return 4 using the current string we have

local increment = x/10

-- here we can divide the number returned by 10, giving us the decimal
-- if you have just a number in the string, lua will use it as a number
-- otherwise it will error

-- we then add the Size
Object.Size +=, 0, increment)

for this, you should probably use a regular for loop, which is just a single variable counting up (or down)

for i = 1, 10 do
    -- this loop will run 10 times
    -- it starts at 1, and will end at 10

    -- we can use this on a table, by changing 10, to
    -- the number of items in our table, and then using "i"
    -- to get the objects, and apply the correct data

    local v = children[i] -- our part
    local x = string.sub(v.Name, 3, #v.Name) -- gets number from name
    children[i].Size +=, 0, x/10) -- increments Size

Yes, I absolutely loved your commenting, I figured out by doing it this way, it works.

local wallBaseName = "kp"
local wallCount = 30

local x = 0
for i = 1, wallCount do
    local wallName = wallBaseName .. i
    local wall = game.Workspace["Lava Wall Jump"]:FindFirstChild(wallName)

    if wall then
        wall.Size = wall.Size +, 0, x)
        x = x + 0.1
        warn("Wall not found:", wallName)

I did some more brainstorming with your method, I figured out how to make the obby build its self!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.