How to ungroup a model with its name randomized using a script

So I want to ungroup a model using a script as said in the title but the name of the parent model is being randomized.

My issues here is that I am unable to search for the model as the name it being randomized, I do not know how to get the model via its name.

I am currently using a script whereby I move the children under workspace and then destroy the empty model. I have tried to use strings and magic characters but I am still unable to get the model via a script.

1 Like

Can you show script where model get random name?

1 Like

It is necessary to save references to the model in the table initially and search in the table

Maybe just do all the math or stuff,
Then set the name youre going to set as a variable, local name = --whatever you called the random name variable
Then thats your name.

However, I am not sure this is going to work, but you can maybe store it in a table and do this:

local modelTable = {
   model
}

-- do all the random name stuff

local newModel = modelTable.model
1 Like

Hi I will get back to you tmr and uh I accidentally clicked on the solution button. And for context the names are actually from a spawner as the supposed model is a vehicle and the name is being changed to “player’s name” follows by a extra “Car” behind. The name of the model only changes once, when the vehicle spawn. I’ll send in the photo once I’m free.