In my script, I have this function that checks if there is a value called "Status".
NOTE: THERE IS CODE IN BETWEEN THE LOOPS AND IF STATEMENTS THAT I DIDN'T SHOW
local function recursive(model) for _,child in pairs(model:GetChildren()) do for _,descendant in pairs(child:GetChildren()) do if descendant:IsA("StringValue") and descendant.Name:lower() =="status" then if string.sub(descendant.Value,1,4):lower() == "jump" then --code elseif string.sub(descendant.Value,1,5):lower() == "speed" then --code elseif string.sub(descendant.Value,1,4):lower() == "kill" then --code end else recursive(descendant) end end end end recursive(newMap) -- newMap is declared before in the actual script
newMap is a map that is being cloned into Workspace. I have declared this variable before so you don't have to worry about that.
Status is supposed be in a model, not added.
As you can see, I am using recursion. However, I want to avoid using recursion as much as possible for good performance in my game. Is there an alternative to recursion?
This is the most confusing question. You named the function recursive and you want to know how to stop recursion? Maybe edit the names you grabbed from the freemodel to show more of what you'd like to do.