#fast question about a loop.

1 messages · Page 1 of 1 (latest)

sinful patrol
#

for _, barry in pairs(barrytable) do
if barry then
print("barry found.")

this is printing barry found only one time, even if the elements inside the barrytable are 5, why?

#

and they all named barry

junior flame
#

if barry then is true all the time except if the value is false

#

show the whole code next time plz

sinful patrol
#

ill show it now

proper barnBOT
#

studio** You are now Level 9! **studio

junior flame
# sinful patrol ill show it now

y tho i just told you, if barry then is only checking the truthiness of the value. it doesnt matter if its an instance named barry or not.

sinful patrol
#

wait a sec ill send the script

#
local bushpart = game.Workspace:WaitForChild("BushPart")
local barriesfolder = bushpart:WaitForChild("Barries")



function foundbarries()
local barriestables = {} 
for _, barry in pairs(barriesfolder:GetChildren()) do
    if barry then
        table.insert(barriestables, barry)
        print("barry found")
        barry.Size = Vector3.new(0,0,0)
    end
end
    return barriestables 
end


local barrytable = foundbarries()
print(#barrytable)
for _, barry in pairs(barrytable) do
    if barry then
    print("barry found",_)
local growth = barry:FindFirstChildWhichIsA("BoolValue")
local prompt = barry:FindFirstChildWhichIsA("ProximityPrompt")
for i = 0, 3 do
    barry.Size = barry.Size + Vector3.new(0.1,0.1,0.1)
    task.wait(3)
    print("barry size updated")
    end
    growth.Value = true
    prompt.Enabled = true
    end
end

junior flame
#

local script or serverscript?

sinful patrol
#

server

#

all elements are in the table i checked

junior flame
#

whats wrong with it

sinful patrol
#

im doing something wrong with the 2nd loop

sinful patrol
#

for i = 0, 3 do
barry.Size = barry.Size + Vector3.new(0.1,0.1,0.1)
task.wait(3)
print("barry size updated")
end
growth.Value = true
prompt.Enabled = true

#

this works only for one berry

junior flame
#

maybe there's only one

#

your code only runs once so there's that

#

use collectionservice maybe

#

also ☠️ grow a garden clone

#

if you stuck on this you aint no chance at the offline thing hehe

sinful patrol
#

btw

#

what do you mean by using collectionservice

#

why would i need that

junior flame
sinful patrol
#

but i dont find reason to use it there

#

broo im so confused this should be easy

#

what is wrong with that loop

#

every berry should grow

junior flame
#

where is this script

#

and is this the whole script

sinful patrol
#

serverscript

sinful patrol
#

maybe

#

some debug lines?

#

to see

#

but as i said print("barry found",_)
it prints barry found 1

junior flame
#

check your explorer to see if there's more than 1 in the right place etc

sinful patrol
#

the weird thing is that if i check the table before the loop it gives all the 5 berries, but inside the loop i get only one

junior flame
junior flame
sinful patrol
#

every 3 seconds it grows

junior flame
#

which i'm sure has nothing to do with an attempted first berry bush of a grow a garden clone idk im just saying stuff for the sake of saying stuff at this point

sinful patrol
#

is it wrong?

junior flame
#

good luck salute

sinful patrol
sinful patrol
#

not every bush means is grow a garden, im learning scripting and i tought this was a good thing to start

#

why would i lie to you xd

#

i appreciate the suggestions but i dont understood why did u get mad over the fact that im cloning a game

#

even if i was doing that its still a great thing to "replicate systems" to learn

junior flame
junior flame
sinful patrol
sinful patrol
junior flame
#

for weeks before dead rails it's been mostly tsb clones, it's nice to see beginners moving onto something arguably much easier to make than a combat system or making trains follow a path of rails or procedural generation etc

#

there's only been a couple of questions about procedurally generating plants ;p

junior flame