unity how to make infinite train? code example

Example: how to make an automatic regen script on roblox

model = game.Workspace.Heads -- Change "Heads" to the name of the model you want to regen 
messageText = "Regenerating Heads Changers..." -- Change this to what you want the message to say

message = Instance.new("Message")
message.Text = messageText
backup = model:clone()

while true do
	wait(4) -- Change this when you want your model to regenerate in seconds

	message.Parent = game.Workspace
	model:remove()

	wait(2) -- display regen message for 2 seconds

	model = backup:clone()
	model.Parent = game.Workspace
	model:makeJoints()
	message.Parent = nil
end

Tags:

Lua Example