Yes, you make the function return the solution inside the function. So, say that you want to set the body position after creating the new pet. You would run the function as the body position property when setting it so it will return the body position and set it. It should looks like this.
[#Pets + 1] = Pet--Set the new pet's index number within the table's dictionary so it can be easily indexed.
local function GetBodyPosition(Pet)
local IndexNumber = 0
for I, V in next do
IndexNumber += IndexNumber
if V == Pet then
Position = CircularEquation(IndexNumber)
Use the dictionary index integer in a function to get the position based on its index integer and the total amount of pets currently in the table.
Pet.Model.PrimaryPart.BodyPosition.Position = GetBodyPosition(Pets[Pet])
--This will run the function with a parameter of the Pet's index integer so that it can get the position based off the returned value(result of the equation using the Pet's index integer.)
When you add a new
Pet to the
Pets table you should do this to make sure it’s added to the dictionary with an index integer. When you want to remove a pet use its integer from a saved value, or something like that.