So I want to make a script that does a formula automatically using a parent name.
As you can see there’s multiple models with names from 1 to 9. I have one script located in each of these models and I want it to select the Parent name using tonumber(Part.Name). I have this for now:
local Cost = tonumber(script.Parent.Parent["1"].Name)
local Amount = tonumber(script.Parent.Parent["1"].Name)
The problem is that I don’t want to always change the [“1”] to the model name, I want it to be automatic… So is there a way to select automatically the Parent of where the script is, like only the model of where the script is located without having to change something everytime since it needs to be automatic.
I don’t think that’s what i’m looking for. What I want is to “extract” a Parent name automatically:
When I type script.Parent.Parent. it shows me multiple things:
In this case, it shows me all the models from 1 to 9. But I don’t want to type script.Parent.Parent["1"].Name for the first script, then to change this to script.Parent.Parent["2"].Name because I have multiple scripts that I need to duplicate hundreds of times.