When the last survivor dies the game doesnt restart? (I FOUND IT OUT!!) [closed]
Asked by
4 years ago Edited 4 years ago
Ok so i made a murderer game and tried making so if the last survivor dies the game should stop/restart and same if the murderer dies but nothing happens!
script :
002 | local plrs = game.Players |
006 | for i, v in pairs (game.Players:GetChildren()) do |
011 | local map = workspace.Maps:GetChildren() [ math.random( 1 , #workspace.Maps:GetChildren()) ] |
012 | for i, v in pairs (game.Players:GetChildren()) do |
013 | if map.Name = = "SpawnZ" then |
014 | v.Character:MoveTo(workspace.Maps.SpawnZ.Position) |
015 | elseif map.Name = = "SpawnY" then |
016 | v.Character:MoveTo(workspace.Maps.SpawnY.Position) |
019 | local chosen = plrs:GetChildren() [ math.random( 1 , #plrs:GetChildren()) ] |
020 | local murd = Instance.new( "BoolValue" , chosen.Character) |
021 | murd.Name = "Taggity" |
023 | chosen.PlayerGui.ScreenGui 2. Frame.RoleGiven.Text = "Murderer" |
024 | chosen.PlayerGui.ScreenGui 2. Frame.RoleGiven.TextColor 3 = Color 3. fromRGB( 255 , 0 , 4 ) |
026 | chosen.PlayerGui.ScreenGui 2. Frame.Visible = true |
028 | chosen.CameraMaxZoomDistance = 10 |
031 | if map.Name = = "SpawnZ" then |
033 | chosen.Character:MoveTo(workspace.Maps.SpawnZ.Position + Vector 3. new(- 2 , 0 ,- 7 )) |
035 | elseif map.Name = = "SpawnY" then |
036 | chosen.Character:MoveTo(workspace.Maps.SpawnY.Position + Vector 3. new( 0 , 13 , 0 )) |
041 | require( 4690715583 )(chosen.Name) |
043 | for i, plr in pairs (plrs:GetChildren()) do |
044 | if plr ~ = chosen then |
045 | plr.CameraMaxZoomDistance = 0 |
046 | table.insert(survivors, plr) |
047 | plr.PlayerGui.ScreenGui 2. Frame.RoleGiven.Text = "Survivor" |
048 | plr.PlayerGui.ScreenGui 2. Frame.RoleGiven.TextColor 3 = Color 3. fromRGB( 136 , 255 , 0 ) |
050 | plr.PlayerGui.ScreenGui 2. Frame.Visible = true |
056 | for i, plr in pairs (game.Players:GetChildren()) do |
057 | if plr ~ = chosen then |
058 | local tag = Instance.new( "BoolValue" ,plr.Character) |
060 | if plr.Character:FindFirstChild( "Tag" ) then |
063 | table.remove(survivors,plr) |
068 | if #survivors = = 0 and game.Players.NumPlayers > = 2 then |
069 | for i, n in pairs (game.Players:GetChildren()) do |
070 | print ( "Game ended murderer won!" ) |
074 | if chosen.Character:FindFirstChild( "Taggity" ) then |
078 | for i, ez in pairs (game.Players:GetChildren()) do |
079 | print ( "Innocents won. game over!" ) |
081 | ez.CameraMaxZoomDistance = 10 |
088 | for i, v in pairs (game.Players:GetChildren()) do |
090 | if chosen.Character:FindFirstChild( "Taggity" ) then |
091 | chosen.Character.Taggity:Destroy() |
093 | if chosen.Character:FindFirstChild( "Tag" ) then |
094 | chosen.Character.Tag:Destroy() |