How do I make all models in my roblox game world regenerate when the round restarts?
I have seen many model regeneration scripts that go by time but this is not what I want. I want a script that regenerates the models when my lobby script restarts (the lobby script I am using detects when all players have died and then teleports them out of the lobby and into the game play area).
Lobby script:
04 | function teleportAllPlayers() |
05 | local target = CFrame.new(workspace.TeleportTarget.Position) |
06 | for i, player in ipairs (game.Players:GetChildren()) do |
07 | player.Character.Torso.CFrame = target + Vector 3. new( 0 , i * 5 , 0 ) |
08 | player.Playing.Value = 1 |
13 | function message(message) |
14 | if oldMessage ~ = message then |
20 | function playersCurrentlyPlaying() |
21 | for i, player in ipairs (game.Players:GetChildren()) do |
22 | if player.Playing.Value = = 1 then return true end |
27 | game:GetService( 'Players' ).PlayerAdded:connect( function (player) |
28 | player.CharacterAdded:connect( function (character) |
29 | character:WaitForChild( "Humanoid" ).Died:connect( function () |
30 | player.Playing.Value = 0 |
34 | local playing = Instance.new( "IntValue" , player) |
36 | playing.Name = "Playing" |
42 | if #game.Players:getPlayers() > = minPlayers then |
43 | if playersCurrentlyPlaying() then |
44 | message( "Waiting for the current game to end..." ) |
46 | message( "There are enough players for a new game! Teleporting..." ) |
50 | else message( "Waiting for more players..." ) end |
Sorry if I goofed up while asking this question, this is my first time using this website.