Game round loop? script is not repeating
Hello.
I recently started making a round-based game called 'Jeff'. But after 1 round, my script doesn't return to the start (picking a map, killer etc) it just loops the gameplay. Can somebody help me?
There is a normal script and a module script, both in server script service
Normal script:
004 | local IntermissionRoundRemote = game.ReplicatedStorage:WaitForChild( "IntermissionFrame" ) |
005 | local LightningOfKiller = game.ReplicatedStorage:WaitForChild( "LightningOfJeff" ) |
006 | local Round = require(script:WaitForChild( "Intermission" )) |
012 | game.ReplicatedStorage.Status.Value = "Game starting soon!" |
024 | game.ReplicatedStorage.Status.Value = "Map loaded!" |
028 | game.ReplicatedStorage.Status.Value = "Intermission..." |
029 | game.Workspace.GameMusic.Boom:Play() |
033 | IntermissionRoundRemote:FireAllClients(game.Players:GetChildren()) |
041 | for i, v in pairs (game.Players:GetChildren()) do |
043 | table.insert(PLRS, v) |
045 | if v.Name = = game.ReplicatedStorage.KillerName.Value then |
046 | table.remove(PLRS, i) |
051 | local function toMS(s) |
052 | return ( "i:i" ):format(s/ 60 % 60 , s% 60 ) |
055 | for Countdown = 180 , 0 ,- 1 do |
056 | game.ReplicatedStorage.Status.Value = toMS(Countdown).. " left!" |
060 | game.ReplicatedStorage.Status.Value = "All Players have died!" |
064 | for i, Song in pairs (game.Workspace.GameMusic:GetChildren()) do |
070 | game.ReplicatedStorage.LightningOfJeffBack:FireClient(game.Players:FindFirstChild(game.ReplicatedStorage.KillerName.Value)) |
072 | for i, v in pairs (game.Players:GetChildren()) do |
076 | game.Players:FindFirstChild(game.ReplicatedStorage.KillerName.Value).leaderstats.Money.Value = game.Players:FindFirstChild(game.ReplicatedStorage.KillerName.Value).leaderstats.Money.Value + 50 |
078 | v.Character.HumanoidRootPart.CFrame = game.Workspace.MenuTeleportPart.CFrame + Vector 3. new( 0 , 10 , 0 ) |
080 | if game.Workspace:FindFirstChild( "Store" ) then |
081 | game.Workspace.Store:Destroy() |
084 | if game.Workspace:FindFirstChild( "Forest" ) then |
085 | game.Workspace.Forest:Destroy() |
092 | if Countdown = = 0 then |
094 | game.ReplicatedStorage.Status.Value = "Time's up!" |
098 | for i, Song in pairs (game.Workspace.GameMusic:GetChildren()) do |
104 | game.ReplicatedStorage.LightningOfJeffBack:FireClient(game.Players:FindFirstChild(game.ReplicatedStorage.KillerName.Value)) |
106 | for i, v in pairs (game.Players:GetChildren()) do |
110 | v.Character.HumanoidRootPart.CFrame = game.Workspace.MenuTeleportPart.CFrame + Vector 3. new( 0 , 10 , 0 ) |
112 | if game.Workspace:FindFirstChild( "Store" ) then |
113 | game.Workspace.Store:Destroy() |
116 | if game.Workspace:FindFirstChild( "Forest" ) then |
117 | game.Workspace.Forest:Destroy() |
122 | if not game.Players:FindFirstChild(game.ReplicatedStorage.KillerName.Value) then |
124 | game.ReplicatedStorage.Status.Value = "Killer has left!" |
126 | for i, Song in pairs (game.Workspace.GameMusic:GetChildren()) do |
134 | for i, v in pairs (game.Players:GetChildren()) do |
138 | v.Character.HumanoidRootPart.CFrame = game.Workspace.MenuTeleportPart.CFrame + Vector 3. new( 0 , 10 , 0 ) |
140 | if game.Workspace:FindFirstChild( "Store" ) then |
141 | game.Workspace.Store:Destroy() |
144 | if game.Workspace:FindFirstChild( "Forest" ) then |
145 | game.Workspace.Forest:Destroy() |
150 | if #PLRS > = 0 and Countdown = = 0 then |
152 | game.ReplicatedStorage.Status.Value = "Killer didn't kill every player!" |
154 | for i, Song in pairs (game.Workspace.GameMusic:GetChildren()) do |
161 | for i, v in pairs (PLRS) do |
163 | v.leaderstats.Money.Value = v.leaderstats.Money.Value + 50 |
165 | game.ReplicatedStorage.LightningOfJeffBack:FireClient(game.Players:FindFirstChild(game.ReplicatedStorage.KillerName.Value)) |
167 | for i, x in pairs (game.Players:GetChildren()) do |
170 | x.Character.HumanoidRootPart.CFrame = game.Workspace.MenuTeleportPart.CFrame + Vector 3. new( 0 , 10 , 0 ) |
173 | if game.Workspace:FindFirstChild( "Store" ) then |
174 | game.Workspace.Store:Destroy() |
177 | if game.Workspace:FindFirstChild( "Forest" ) then |
178 | game.Workspace.Forest:Destroy() |
200 | for FreeTime = 20 , 0 ,- 1 do |
201 | game.ReplicatedStorage.Status.Value = "Waiting for new mission! " ..FreeTime |
Module script (Inside of normal script)
004 | local KillerInWorkspace |
008 | local LightningOfKiller = game.ReplicatedStorage.LightningOfJeff |
010 | function module.Calibrate() |
011 | for i, v in pairs (game.Players:GetChildren()) do |
013 | table.insert(PLRS, v) |
018 | function module.Intermission() |
020 | game.Workspace.GameMusic.Tick:Play() |
021 | game.ReplicatedStorage.Status.Value = "Game starting in " ..i.. " seconds!" |
026 | function module.ChooseTheJeff() |
028 | game.ReplicatedStorage.Status.Value = "Choosing the killer..." |
031 | local Jeff = PLRS [ math.random( 1 ,#PLRS) ] |
034 | game.ReplicatedStorage.Status.Value = "The killer is " ..Jeff.Name.. "!" |
038 | for i, PLRSONE in pairs (PLRS) do |
039 | if PLRSONE = = Jeff then |
040 | table.remove(PLRS, i) |
045 | game.ReplicatedStorage.Status.Value = "The killer" ..Jeff.Name.. " left!" |
047 | game.ReplicatedStorage.KillerName.Value = "" |
052 | game.ReplicatedStorage.KillerName.Value = KillerChosen.Name |
056 | function module.ChooseTheMap() |
058 | game.ReplicatedStorage.Status.Value = "Choosing the map..." |
062 | local Maps = game.ServerStorage.Maps:GetChildren() |
064 | local ChosenMap = Maps [ math.random( 1 ,#Maps) ] |
066 | if ChosenMap ~ = nil then |
067 | game.ReplicatedStorage.Status.Value = "The map is " ..ChosenMap.Name.. "!" |
069 | MapChosen = ChosenMap |
071 | game.ReplicatedStorage.Status.Value = "Failed to choose the map..." |
076 | game.ReplicatedStorage.Status.Value = "Waiting for map to load..." |
078 | ChosenMap.Parent = workspace |
084 | function module.StartTheGame() |
086 | game.ReplicatedStorage.Status.Value = "Teleporting survivors on the map" |
088 | for i, v in pairs (PLRS) do |
090 | local HRP = v.Character:FindFirstChild( "HumanoidRootPart" ) |
093 | table.remove(PLRS, i) |
096 | local Spawners = MapChosen:FindFirstChild( "SpawnPoints" ):GetChildren() |
099 | HRP.CFrame = Spawners [ 1 ] .CFrame + Vector 3. new( 0 , 6 , 0 ) |
100 | table.remove(Spawners, 1 ) |
105 | KillerChosen.Character [ "Body Colors" ] .HeadColor = BrickColor.White() |
106 | KillerChosen.Character [ "Body Colors" ] .LeftArmColor = BrickColor.White() |
107 | KillerChosen.Character [ "Body Colors" ] .RightArmColor = BrickColor.White() |
108 | KillerChosen.Character [ "Body Colors" ] .LeftLegColor = BrickColor.White() |
109 | KillerChosen.Character [ "Body Colors" ] .RightLegColor = BrickColor.White() |
110 | KillerChosen.Character [ "Body Colors" ] .TorsoColor = BrickColor.White() |
111 | KillerChosen.Character.Head.face.Texture = game.ServerStorage.JeffFace.Value |
112 | KillerChosen.Character.Shirt.ShirtTemplate = game.ServerStorage.JeffShirt.Value |
113 | KillerChosen.Character.Pants.PantsTemplate = game.ServerStorage.JeffPants.Value |
117 | for Countdown = 15 , 0 ,- 1 do |
118 | game.ReplicatedStorage.Status.Value = "Hide! The killer will be here in " ..Countdown.. " seconds!" |
122 | game.ReplicatedStorage.Status.Value = "Hide! The killer is coming!" |
126 | local Songs = { game.Workspace.GameMusic.Music 1 , game.Workspace.GameMusic.Music 2 , game.Workspace.GameMusic.Music 3 , game.Workspace.GameMusic.Music 4 } |
128 | local ChosenGameSong = Songs [ math.random( 1 ,#Songs) ] |
129 | ChosenGameSong:Play() |
131 | if not KillerChosen then |
132 | game.ReplicatedStorage.Status.Value = "The killer has left! Reojoin the game because im an idiot and i dont know what do i do :DDDD" |
134 | KillerChosen.Character:FindFirstChild( "HumanoidRootPart" ).CFrame = MapChosen.KillerSpawn.CFrame + Vector 3. new( 0 , 6 , 0 ) |
135 | local ClonedKnife = game.ServerStorage.Knife:Clone() |
137 | ClonedKnife.Parent = KillerChosen.Backpack |
139 | game.ReplicatedStorage.Status.Value = "The killer is on the map!" |
142 | LightningOfKiller:FireClient(KillerChosen) |
Thank you