I am trying to make an elevator game but this while loop keeps not working as it's supposed to. There are no errors, it just will not run. Here's all of my code.





local plrs = {}
	game.Workspace:WaitForChild("TpCframe1").Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and db == false then
				db = true
			    hit.Parent.HumanoidRootPart.CFrame = game.Workspace.TpCframe2.CFrame
			    local player = game.Players:GetPlayerFromCharacter(hit)
			    if not table.find(plrs,player) then -- detecting if player is not in the table
					  table.insert(plrs,player) -- adding player in table
					    print("Added player to table.")
			wait(1)
			db = false
			
			end
		end
	end)
while true do
	wait(0.01)
    if #plrs >= 1 then
        wait(1)
        for i = 10,0,-1 do
            wait(1)
            game.ReplicatedStorage.Timer.Value = i
            if i == 0 then
                local event = game.ServerStorage.Floors:GetChildren()
                local chosenEvent = event[math.random(1,#event)]
                local clonedEvent = chosenEvent:Clone()
                clonedEvent.Parent = workspace
                wait(2)
                open()
                wait(0.5)
                if chosenEvent.Name == "No Chill" then
                    clonedEvent.Board.chill.Face = Enum.NormalId.Front
                    wait(1)
                    clonedEvent.Board.chill.Face = Enum.NormalId.Top
                    clonedEvent.Board.wrong.Face = Enum.NormalId.Front
                    game.Workspace["WRONG!"]:Play()
                    wait(1)
                    clonedEvent.Board.checkit.Face = Enum.NormalId.Front
                    clonedEvent.Board.wrong.Face = Enum.NormalId.Top
                    wait(1)
                    clonedEvent.Board.checkit.Face = Enum.NormalId.Top
                    clonedEvent.Board.correct.Face = Enum.NormalId.Front
                    game.Workspace.correct:Play()
                    wait(1)
				                end
				for i,v in pairs(game.Players:GetPlayers()) do
					if v then
						v.Character:WaitForChild("Humanoid").Died:Connect(function()
							table.remove(plrs,v)
						end)
					end
				end
				game.Players.PlayerRemoving:Connect(function(plr)
					table.remove(plrs,plr)
				end)
                wait(15)
				clonedEvent:Destroy()
				break
            end
        end
    end
    wait()
end



4 comments

0

You've already asked this question before, please don't spam. Moderation started.

0

And the question was not answered.

0

i meant duplicate lmao