<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.starfall.wtf/index.php?action=history&amp;feed=atom&amp;title=How_to_Make_a_Model_Regenerate</id>
	<title>How to Make a Model Regenerate - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.starfall.wtf/index.php?action=history&amp;feed=atom&amp;title=How_to_Make_a_Model_Regenerate"/>
	<link rel="alternate" type="text/html" href="https://wiki.starfall.wtf/index.php?title=How_to_Make_a_Model_Regenerate&amp;action=history"/>
	<updated>2026-07-28T16:15:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.starfall.wtf/index.php?title=How_to_Make_a_Model_Regenerate&amp;diff=424&amp;oldid=prev</id>
		<title>PRG: Created page with &quot;{{CatUp|Tutorials}} {{ScriptTutorial|Basic|Model}} __TOC__  == Introduction ==  Are you making a BrickBattle game and you want to have your scenery regenerate every once in a while? It is possible to do this with scripting.  This tutorial will show you how to make a model regenerate every 5 minutes and display a message to this effect.  == Make a model ==  The first step is to group the part of your level you want to regenerate into a model.  Give your model a descri...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.starfall.wtf/index.php?title=How_to_Make_a_Model_Regenerate&amp;diff=424&amp;oldid=prev"/>
		<updated>2024-12-10T12:51:07Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{CatUp|Tutorials}} {{ScriptTutorial|Basic|Model}} __TOC__  == Introduction ==  Are you making a &lt;a href=&quot;/index.php/BrickBattle&quot; title=&quot;BrickBattle&quot;&gt;BrickBattle&lt;/a&gt; game and you want to have your scenery regenerate every once in a while? It is possible to do this with scripting.  This tutorial will show you how to make a model regenerate every 5 minutes and display a message to this effect.  == Make a model ==  The first step is to group the part of your level you want to regenerate into a model.  Give your model a descri...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{CatUp|Tutorials}}&lt;br /&gt;
{{ScriptTutorial|Basic|Model}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Are you making a [[BrickBattle]] game and you want to have your scenery regenerate every once in a while? It is possible to do this with scripting.  This tutorial will show you how to make a model regenerate every 5 minutes and display a message to this effect.&lt;br /&gt;
&lt;br /&gt;
== Make a model ==&lt;br /&gt;
&lt;br /&gt;
The first step is to group the part of your level you want to regenerate into a model.  Give your model a descriptive name.  For example, in [[Crossroads]], the part of Black Rock Castle that regenerates is grouped as a model called BlackRockCastle.&lt;br /&gt;
&lt;br /&gt;
== Insert a Script Into the Workspace ==&lt;br /&gt;
&lt;br /&gt;
Go to Insert -&amp;gt; Object and when the box pops up click on the script object.  This puts a script in your workspace.  You should name it something descriptive like &amp;quot;RegenScript&amp;quot; (this is not strictly necessary but is a good practice to get into).&lt;br /&gt;
&lt;br /&gt;
== Edit the Script ==&lt;br /&gt;
&lt;br /&gt;
Copy and paste this code into the Script you just created.  Replace &amp;quot;MyModelName&amp;quot; with the name of your model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
model = game.Workspace.MyModelName&lt;br /&gt;
messageText = &amp;quot;Regenerating MyModelName...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
message = Instance.new(&amp;quot;Message&amp;quot;)&lt;br /&gt;
message.Text = messageText&lt;br /&gt;
backup = model:clone()&lt;br /&gt;
&lt;br /&gt;
while true do&lt;br /&gt;
	wait(300) -- regenerate this model every 300 seconds&lt;br /&gt;
&lt;br /&gt;
	message.Parent = game.Workspace&lt;br /&gt;
	model:remove()&lt;br /&gt;
&lt;br /&gt;
	wait(4) -- display regen message for 4 seconds&lt;br /&gt;
&lt;br /&gt;
	model = backup:clone()&lt;br /&gt;
	model.Parent = game.Workspace&lt;br /&gt;
	model:makeJoints()&lt;br /&gt;
	message.Parent = nil&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Save and Exit ==&lt;br /&gt;
&lt;br /&gt;
Since scripts are constantly running, changes to them do not take effect until you exit and reload a level OR cut the script and paste it back (using the explorer tab). You should now see your model regenerating every 5 minutes.&lt;br /&gt;
&lt;br /&gt;
== Regeneration Buttons ==&lt;br /&gt;
&lt;br /&gt;
To create a regeneration button, create a script, place it in the button, and copy this code into the script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
model = game.Workspace.MyModelName&lt;br /&gt;
messageText = &amp;quot;Regenerating MyModelName...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
message = Instance.new(&amp;quot;Message&amp;quot;)&lt;br /&gt;
message.Text = messageText&lt;br /&gt;
backup = model:clone()&lt;br /&gt;
enabled = true&lt;br /&gt;
&lt;br /&gt;
function regenerate()&lt;br /&gt;
	message.Parent = game.Workspace&lt;br /&gt;
	model:remove()&lt;br /&gt;
&lt;br /&gt;
	wait(4) -- display regen message for 4 seconds&lt;br /&gt;
&lt;br /&gt;
	model = backup:clone()&lt;br /&gt;
	model.Parent = game.Workspace&lt;br /&gt;
	model:makeJoints()&lt;br /&gt;
	message.Parent = nil&lt;br /&gt;
&lt;br /&gt;
	enabled = false&lt;br /&gt;
	wait(30)&lt;br /&gt;
	enabled = true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onHit(hit)&lt;br /&gt;
	if (hit.Parent:FindFirstChild(&amp;quot;Humanoid&amp;quot;) ~= nil) and enabled then&lt;br /&gt;
		regenerate()&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
script.Parent.Touched:connect(onHit)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change &amp;quot;MyModelName&amp;quot; to the name of the model you want to regenerate, and you&amp;#039;re done.&lt;br /&gt;
&lt;br /&gt;
== Tips ==&lt;br /&gt;
&lt;br /&gt;
If you have a large map, try not to regenerate the whole thing at once, which will cause massive lag.  Break your map up into a couple of sections, each of which regenerates on its own.  Another thing to keep in mind is that a model is temporarily removed from the game when it is regenerating, which can cause players standing on the model to fall.  Sometimes the model will then regenerate such that the player is then trapped &amp;#039;&amp;#039;&amp;#039;inside&amp;#039;&amp;#039;&amp;#039; of some bricks, which is bad.&lt;br /&gt;
&lt;br /&gt;
If you have problems, look at [[Crossroads]] or [[Chaos Canyon]] for an example of a working regeneration script (the scripts in those maps look a little different - in particular the regen period is random - but work the same way).&lt;br /&gt;
&lt;br /&gt;
==Easy Regeneration Script==&lt;br /&gt;
&lt;br /&gt;
This script is very easy to use just put it in the model set the time between regenerations (if you dont want 300 secs):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---Place this INSIDE the model.  Don&amp;#039;t replace the model name or anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
object = script.Parent &lt;br /&gt;
if (object ~= nil) and (object ~= game.Workspace) then &lt;br /&gt;
model = object &lt;br /&gt;
messageText = &amp;quot;regenerating &amp;quot; .. model.Name .. &amp;quot;&amp;quot; &lt;br /&gt;
&lt;br /&gt;
message = Instance.new(&amp;quot;Message&amp;quot;) &lt;br /&gt;
message.Text = messageText &lt;br /&gt;
backup = model:clone() -- Make the backup &lt;br /&gt;
waitTime = 180 --Time to wait between regenerations &lt;br /&gt;
wait(math.random(0, waitTime)) &lt;br /&gt;
while true do &lt;br /&gt;
wait(waitTime) -- Regen wait time &lt;br /&gt;
&lt;br /&gt;
message.Parent = game.Workspace &lt;br /&gt;
model:remove() &lt;br /&gt;
&lt;br /&gt;
wait(2.5) -- Display regen message for this amount of time &lt;br /&gt;
&lt;br /&gt;
model = backup:clone() &lt;br /&gt;
model.Parent = game.Workspace &lt;br /&gt;
model:makeJoints() &lt;br /&gt;
message.Parent = nil &lt;br /&gt;
end &lt;br /&gt;
end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Error messages: &amp;lt;b&amp;gt;Attempt to set parent of Workspace to Workspace.Model results in circular reference:&amp;lt;/b&amp;gt; Do not group Workspace together when creating your Regen model.  You can group everything else underneath Workspace.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;/div&gt;</summary>
		<author><name>PRG</name></author>
	</entry>
</feed>