ok let me explain real quick, i have made a recursive function which doenst return anything. i have tried making a variable and then changing the variable with the function but it didnt work
local function getLowestBranch(branch)
if branch:FindFirstChild("Rodzic") ~= nil then
local lowerbranch = branch.Rodzic.Value
getLowestBranch(lowerbranch)
else
return branch
end
end
Make it return getLowestBranch(lowerbranch) or else the initial call on the function will never return a value. Another way you could do this is by simply using a while loop:
local function getLowestBranch(branch)
while true do
if not branch:FindFirstChild("Rodzic") then
return branch
else
branch = branch.Rodzic.Value
end
end
end
I see a problem here. You forgot to add the function keyword in front of the first line, so the script doesn’t perceive it as a function, which is why it’s confused about that last end
local function getLowestBranch(branch)
if branch:FindFirstChild("Rodzic") ~= nil then
local lowerbranch = branch.Rodzic.Value
getLowestBranch(lowerbranch)
else
return branch
end
end
and here’s the solution. See if you can find what changed
local function getLowestBranch(branch)
if branch:FindFirstChild("Rodzic") ~= nil then
local lowerbranch = branch.Rodzic.Value
return getLowestBranch(lowerbranch)
else
return branch
end
end