so im trying to create a tree growing system and i made a module script responsible for growing functions. so the first function is working fine, but the second one is not firing at all.
local module = {}
module.plantSadzonka = function(nazwadrzewa,nazwabiomu,pozycja,wybranyPart)
local regionTreeModel = workspace:FindFirstChild("TreeRegion_"..nazwabiomu)
local moduledrzewa = require(game.ServerScriptService.Drzewa.RodzajeDrzew:FindFirstChild(nazwadrzewa))
local sadzonkaModel = Instance.new("Model",regionTreeModel)
sadzonkaModel.Name = "Drzewo"
local sadzonka = Instance.new("Part",sadzonkaModel)
sadzonka.Name = "Drewno"
sadzonka.Anchored = true
sadzonka.BrickColor = moduledrzewa.kolory.kora
sadzonka.Material = moduledrzewa.material.kora
local treeClass = Instance.new("StringValue",sadzonkaModel)
treeClass.Name = "RodzajDrzewa"
treeClass.Value = nazwadrzewa
sadzonka.Orientation = Vector3.new(math.random(moduledrzewa.katsadzonki.minimalny,moduledrzewa.katsadzonki.maksymalny),math.random(moduledrzewa.katsadzonki.minimalny,moduledrzewa.katsadzonki.maksymalny),math.random(moduledrzewa.katsadzonki.minimalny,moduledrzewa.katsadzonki.maksymalny))
sadzonka.Size = Vector3.new(moduledrzewa.sadzonkaWielkosc.grubosc,moduledrzewa.sadzonkaWielkosc.wysokosc,moduledrzewa.sadzonkaWielkosc.grubosc)
sadzonka.Position = wybranyPart.Position + pozycja
end
module.rosniecieLoop = function(sadzonka,rodzajdrzewa,growspeed)
local moduledrzewa = require(game.ServerScriptService.Drzewa.RodzajeDrzew:FindFirstChild(rodzajdrzewa))
while true do
wait(math.random(moduledrzewa.odstepmiedzywzrostami.minimalny,moduledrzewa.odstepmiedzywzrostami.maksymalny)/growspeed)
sadzonka.Size = sadzonka.Size + Vector3.new(moduledrzewa.wzrostsadzonki.grubosc,moduledrzewa.wzrostsadzonki.wysokosc,moduledrzewa.wzrostsadzonki.grubosc)
end
end
return module
its in polish so you may not understand but it doesnt matter, because the problem is that the second function doenst fire at all. i tried putting a print() on the beginning and it didnt print. any help appreciated i couldnt find anything on the internet.
heres the script that fires the function (the not working function is on the bottom):
local regionTreeModel = Instance.new("Model",workspace)
regionTreeModel.Name = "TreeRegion_Test"
local nazwabiomu = "Test"
--drzewka
local drzewo1 = "Test"
local drzewo1module = require(game.ServerScriptService.Drzewa.RodzajeDrzew:FindFirstChild(drzewo1))
rzadkosc1 = 100
--koniec drzewek
local growingmodule = require(game.ServerScriptService.Drzewa.Rosniecie)
local region = workspace.Regiony.Region_Test
local growParts = {}
local limitdrzew = 25
local growspeed = 1 -- im wiekszy tym mniejsze odstepy pomiedzy wzrostami
local growdelay = 0.5 -- im wiecej tym wolniej beda sie pojawiac sadzonki
local growrate = 5 -- im wiecej tym mniejsze szanse na to ze urosnie (nie dawac przecinka)
repeat
wait(growdelay)
if math.random(1,growrate) == 1 then
for i,v in pairs(region:GetDescendants()) do
if v.Name == "Ziemia" then
table.insert(growParts,v)
end
end
local growablePart = growParts[math.random(1,#growParts)]
local pozycja = Vector3.new(math.random(-growablePart.Size.X/2,growablePart.Size.X/2),growablePart.Size.Y/2,math.random(-growablePart.Size.Z/2,growablePart.Size.Z/2))
growingmodule.plantSadzonka(drzewo1,"Test",pozycja,growablePart)
end
until #regionTreeModel:GetChildren() >= limitdrzew
regionTreeModel.ChildRemoved:Connect(function()
repeat
if #regionTreeModel:GetChildren() < limitdrzew then
wait(growdelay)
if math.random(1,growrate) == 1 then
for i,v in pairs(region:GetDescendants()) do
if v.Name == "Ziemia" then
table.insert(growParts,v)
end
end
local growablePart = growParts[math.random(1,#growParts)]
local pozycja = Vector3.new(math.random(-growablePart.Size.X/2,growablePart.Size.X/2),growablePart.Size.Y/2,math.random(-growablePart.Size.Z/2,growablePart.Size.Z/2))
growingmodule.plantSadzonka(drzewo1,nazwabiomu,pozycja,growablePart)
end
end
until #regionTreeModel:GetChildren() >= limitdrzew
end)
regionTreeModel.ChildAdded:Connect(function(child)
local sappling = child:FindFirstChild("Drewno")
growingmodule.rosniecieLoop(sappling,drzewo1,growspeed)
end)