Regen something upon game start

I’d recommend changing them, can you show me your explorer hierarchy of the regenbuttons?

because a quick way to change all the scripts would be to

  • Make a script
  • paste the code
  • Select the script and copy it
  • Select your regen button and Do CTRL + SHIFT + V
  • And delete the old regen

Well each ride is grouped, then inside that is smaller groups of different parts. I just alt + click on the regen button to directly access it, so i could just go around each ride selecting the button and pasting the new script in?

Yup, you can select multiple of your parts with shift + alt + click and then do ctrl + shift + v

@PCHDB
thats easier, you can do that

Or i could search for regenbutton in the explorer, i think they’re all named the same…

Just put the script in ServerScriptService for organisation sakes, it would also work in workspace, and run the code straight away, outnside of the event.

Wouldn’t i need to delete the old scipts though? Like i dont think i can select them all and just delete?

The scripts are linked to what they’re located in, so im not sure it would be able to locate the ride?

Are all the rides parented to the same object? Like are they all inside of one folder

Not currently, but that might be a good idea if it wont mess up the locations of them currently?

No, if you re-parent them to a folder that wouldn’t affect anything. Although that might mess up scripts that references one of the rides and is not inside of that ride. If not, you should be good.

Pretty much, if they’re all inside of a single folder, you can loop through the folder’s children, and regen them.

Ok, thank you. I think so I don’t mess anything else up, i’m just going to search for ‘Regen’ in the explorer, disabled all those scripts then paste in the new one @FastAsFlash_Dev wrote, so i can keep optimised performance. Thank you all for your help!

Would you know how i can make a script inside the rides that would regen them on world startup, but only then and no other time? I only want it for a couple and not all…

Finding out which rides are broken would be a hard thing to implement. Maybe try actually regening all the rides, and see if it lags. I doubt it honestly, it’s just cloning, parenting and making joints. Also you’re gonna do it only once, and at the start of the server where there is only 1 playe, so it’s fine I think.

local folder = game.Workspace.Folder --assuming this is the folder

for i, v in pairs(folder:GetChildren()) do
v:Destroy() --v is the current ride

local back = save:Clone()

back.Parent = location

back:MakeJoints()

end

So even though the rides are grouped inside of the folder, it would still regen them? And would this script go inside of serverscriptservice? My guess is its a normal script and not local too? And finally, i assume the name of the ride groups won’t matter either?

Yeah, it’s regening everything inside the folder.
Yes, it’s a server script, as I said earlier ServerScriptService is a nice place for server scripts.
Yeah it doesn’t matter, v is refering to the current ride.

Ok, ill give it a go now, thank you!

This script doesn’t appear to work, there are some blue squiggles under some of it.
image

The error is pretty obvious. You should be in the call out for things like these. You don’t have save and location defined. I omitted them in the script I sent. Add those variables back.

From my original script? I’m not very good with scripting, sorry! Would this be the location
(local location = script.Parent.Parent.Parent), because surely then it would look for the parent of the parent of the parent of the script in serverscriptservice, and not the ride? Sorry again!

save is the same, location would become the folder now, so instead of that

back.Parent = folder