Answered by
5 years ago Edited 5 years ago
you can't have two while
loops running simultaneously. one loop should be enough to do the job.
EDIT: fixed player checking
001 | local text = game:GetService( 'ReplicatedStorage' ):WaitForChild( 'TextValue' ) |
002 | local Players = game:GetService( 'Players' ) |
005 | local IsPlayingFolder = Instance.new( 'Folder' ) |
006 | IsPlayingFolder.Parent = game:GetService( 'ServerStorage' ) |
008 | function DoubleCheck() |
009 | local pl = #Players:GetChildren() |
017 | workspace.BackGroundMusic:Play() |
019 | PlayersLeft = #Players:GetChildren() |
020 | if PlayersLeft < = 1 then |
021 | text.Value = "Not enough players..." |
022 | print ( "Not enough players" ) |
023 | elseif PlayersLeft > 1 then |
024 | text.Value = "Intermission" |
025 | print ( "Intermission" ) |
029 | if DoubleCheck(PlayersLeft) = = true then |
030 | text.Value = "Not enough players..." |
035 | text.Value = "Game is starting" |
036 | print ( "Game is starting" ) |
040 | for i,v in pairs (Players:GetChildren()) do |
041 | local newValue = Instance.new( "BoolValue" ) |
043 | newValue.Name = v.Name |
044 | newValue.Parent = IsPlayingFolder |
047 | local plrplaying = IsPlayingFolder:GetChildren() |
048 | for i,v in pairs (plrplaying) do |
049 | local num = math.random( 1 , 8 ) |
050 | local plr = Players:FindFirstChild(v.Name) |
051 | if plr and plr.Character and plr.Character:FindFirstChild( "Head" ) then |
052 | plr.Character.Head.CFrame = CFrame.new(workspace.Teleports [ "Part" ..num ] .Position) |
056 | text.Value = "Welcome to Chances of Doom..." |
058 | text.Value = "Let's begin." |
060 | text.Value = "A random player will be eliminated..." |
061 | print ( "a rando will be elim" ) |
063 | workspace.Lightbulb.Lightbulb.Light.Color = Color 3. new( 170 , 0 , 0 ) |
065 | PlayersLeft = Players:GetChildren() |
066 | print ( "Players left: " ..#PlayersLeft) |
067 | if #PlayersLeft > 1 then |
068 | local eliminated = PlayersLeft [ math.random( 1 ,#PlayersLeft) ] |
069 | if eliminated.Character and eliminated.Character:FindFirstChild( 'Humanoid' ) then |
070 | eliminated.Character.Humanoid.Health = 0 |
072 | if IsPlayingFolder:FindFirstChild(eliminated.Name) then |
073 | IsPlayingFolder [ eliminated.Name ] :Destroy() |
077 | text.Value = eliminated.Name.. " has been eliminated." |
079 | elseif #PlayersLeft = = 1 then |
080 | print ( 'Only one person in-game!' ) |
084 | workspace.LightBulb.Lightbulb.Light.Color = Color 3. new( 255 , 255 , 255 ) |
086 | text.Value = "Anyway, let's move on..." |
088 | local PlayersLeftPlaying = IsPlayingFolder:GetChildren() |
089 | if #PlayersLeftPlaying = = 1 then |
090 | text.Value = PlayersLeftPlaying [ 1 ] .Name.. " is the last man standing! Restarting..." |
092 | for i,v in pairs (IsPlayingFolder:GetChildren()) do |